Skip to content

Commit f5c370c

Browse files
committed
test: allow for multiple bazel commands to be run in bazel_integration_test
1 parent 6367a1d commit f5c370c

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

‎internal/bazel_integration_test/bazel_integration_test.bzl‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = {{
4040
testName: '{TMPL_test_name}',
4141
workspaceUnderTest: '{TMPL_workspace_under_test}',
4242
bazelBinaryWorkspace: '{TMPL_bazel_binary_workspace}',
43-
bazelArgs: [ {TMPL_bazel_args} ],
43+
bazelCommands: [ {TMPL_bazel_commands} ],
4444
repositories: {{ {TMPL_repositories} }},
4545
bazelrcAppend: `{TMPL_bazelrc_append}`,
4646
bazelrcImports: {{ {TMPL_bazelrc_imports} }},
@@ -54,7 +54,7 @@ module.exports = {{
5454
TMPL_test_name = ctx.label.name,
5555
TMPL_workspace_under_test = workspace_under_test,
5656
TMPL_bazel_binary_workspace = ctx.attr.bazel_binary.label.workspace_name,
57-
TMPL_bazel_args = ", ".join(["'%s'" % s for s in ctx.attr.bazel_args]),
57+
TMPL_bazel_commands = ", ".join(["'%s'" % s for s in ctx.attr.bazel_commands]),
5858
TMPL_repositories = ", ".join(["'%s': '%s'" % (ctx.attr.repositories[f], _file_to_manifest_path(ctx, f.files.to_list()[0])) for f in ctx.attr.repositories]),
5959
TMPL_bazelrc_append = ctx.attr.bazelrc_append,
6060
TMPL_bazelrc_imports = ", ".join(["'%s': '%s'" % (ctx.attr.bazelrc_imports[f], _file_to_manifest_path(ctx, f.files.to_list()[0])) for f in ctx.attr.bazelrc_imports]),
@@ -102,16 +102,16 @@ $TEST_RUNNER $ARGS "$@"
102102
)]
103103

104104
BAZEL_INTEGRATION_TEST_ATTRS = {
105-
"bazel_args": attr.string_list(
106-
default = ["test", "..."],
107-
doc = """The arguments to pass to Bazel to run the integration workspace test. Defaults to `["test", "..."]`.""",
108-
),
109105
"bazel_binary": attr.label(
110106
default = BAZEL_BINARY,
111107
doc = """The bazel binary files to test against.
112108
113109
It is assumed by the test runner that the bazel binary is found at label_workspace/bazel (wksp/bazel.exe on Windows)""",
114110
),
111+
"bazel_commands": attr.string_list(
112+
default = ["test ..."],
113+
doc = """The list of bazel commands to run. Defaults to `["test ..."]`.""",
114+
),
115115
"bazelrc_append": attr.string(
116116
doc = """String to append to the .bazelrc file in the workspace-under-test.
117117

‎internal/bazel_integration_test/test_runner.js‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,11 @@ if (DEBUG) {
276276
}
277277
}
278278

279-
const bazelArgs = config.bazelArgs.concat(args);
280-
console.log(`\n\nRunning 'bazel ${bazelArgs.join(' ')}'`);
281-
spawnedProcess = spawnSync(bazelBinary, bazelArgs, {cwd: workspaceRoot, stdio: 'inherit'});
282-
283-
// Ensure that this wrapper script exits with the same exit code as the child process.
284-
process.exit(spawnedProcess.status);
279+
for (const bazelCommand of config.bazelCommands) {
280+
const bazelArgs = bazelCommand.split(' ').concat(args);
281+
console.log(`\n\nRunning 'bazel ${bazelArgs.join(' ')}'`);
282+
spawnedProcess = spawnSync(bazelBinary, bazelArgs, {cwd: workspaceRoot, stdio: 'inherit'});
283+
if (spawnedProcess.status) {
284+
process.exit(spawnedProcess.status);
285+
}
286+
}

0 commit comments

Comments
 (0)