豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 03acd84

Browse files
committed
feat(bazel): improve error output on intgeration test failure
We should print the working directory of the test on failure, allowing developers to quickly jump to the test directory on failure. Currently this is hard to spot when the integration test produced a lot of output.
1 parent 9c74c6b commit 03acd84

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

bazel/integration/test_runner/runner.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,31 @@
99
import * as fs from 'fs';
1010
import * as path from 'path';
1111
import * as tmp from 'tmp';
12-
import {addWritePermissionFlag, writeExecutableFile} from './file_system_utils';
13-
import {
14-
PackageMappings,
15-
readPackageJsonContents,
16-
updateMappingsForPackageJson,
17-
} from './package_json';
12+
1813
import {
1914
BazelExpandedValue,
2015
BazelFileInfo,
2116
resolveBazelFile,
2217
resolveBinaryWithRunfilesGracefully,
2318
} from './bazel';
24-
import {debug} from './debug';
19+
import {
20+
PackageMappings,
21+
readPackageJsonContents,
22+
updateMappingsForPackageJson,
23+
} from './package_json';
24+
import {addWritePermissionFlag, writeExecutableFile} from './file_system_utils';
2525
import {
2626
expandEnvironmentVariableSubstitutions,
2727
getBinaryPassThroughScript,
2828
prependToPathVariable,
2929
runCommandInChildProcess,
3030
} from './process_utils';
31+
3132
import {ENVIRONMENT_TMP_PLACEHOLDER} from './constants';
33+
import {debug} from './debug';
34+
35+
/** Error class that is used when an integration command fails. */
36+
class IntegrationTestCommandError extends Error {}
3237

3338
/**
3439
* Test runner that takes a set of files within a Bazel package and copies the files
@@ -230,10 +235,11 @@ export class TestRunner {
230235
);
231236

232237
if (!success) {
233-
throw Error(
234-
`Integration test command: \`${resolvedBinary} ${evaluatedArgs.join(' ')}\` failed. ` +
235-
`See error output above for details.`,
236-
);
238+
console.error(`Command failed: \`${resolvedBinary} ${evaluatedArgs.join(' ')}\``);
239+
console.error(`Command ran in test directory: ${path.normalize(testDir)}`);
240+
console.error(`See error output above.`);
241+
242+
throw new IntegrationTestCommandError();
237243
}
238244
}
239245
}

0 commit comments

Comments
 (0)