aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell
diff options
context:
space:
mode:
authorGravatar ccalvarin <ccalvarin@google.com>2017-10-16 19:21:08 +0200
committerGravatar Jakob Buchgraber <buchgr@google.com>2017-10-18 10:27:48 +0200
commit93c080ad752d029f9f9f9466414430d609105257 (patch)
treeeec7484a61c401779372276a243dde765719a27e /src/test/shell
parent044bc6df1ab73206a955229bdd420795fb7fc2da (diff)
Accept command lines from tools invoking Bazel.
For tools that wrap Bazel in some way, the original way that the tool was invoked can be a useful piece of information to track when logging what Bazel did and why. In order to output this information in the same way that Bazel outputs its command lines, we accept --tool_command_line in the structure command line format that Bazel uses in the BEP. These structured command lines are protos that we expect as a base64 encoded byte array. For simple scripts that wish to use this feature without compiling the proto, we will also accept any old string (that cannot be interpreted as a base64 encoding) as a single "chunk" in a structured command line. This is experimental for now and users should not get attached to the format. We will remove the experimental_ prefix when it is stable. RELNOTES: None. PiperOrigin-RevId: 172341216
Diffstat (limited to 'src/test/shell')
-rwxr-xr-xsrc/test/shell/integration/build_event_stream_test.sh29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/test/shell/integration/build_event_stream_test.sh b/src/test/shell/integration/build_event_stream_test.sh
index 90a712dd11..a647390b55 100755
--- a/src/test/shell/integration/build_event_stream_test.sh
+++ b/src/test/shell/integration/build_event_stream_test.sh
@@ -216,9 +216,11 @@ function test_basic() {
expect_log_once 'tool_tag: "MyFancyTool"'
# Structured command line. Expect the explicit flags to appear twice,
- # in the canonical and original command lines
+ # in the canonical and original command lines. We did not pass a tool
+ # command line, but still expect an empty report.
expect_log 'command_line_label: "original"'
expect_log 'command_line_label: "canonical"'
+ expect_log 'command_line_label: "tool"'
expect_log_n 'combined_form: "-k"' 2
expect_log_n 'option_name: "keep_going"' 2
@@ -740,4 +742,29 @@ EOF
|| fail "not precisely one unconfigured_label event id"
}
+function test_tool_command_line() {
+ bazel build --experimental_tool_command_line="foo bar" --build_event_text_file=$TEST_log \
+ || fail "build failed"
+
+ # Sanity check the arglist
+ expect_log_once 'args: "build"'
+ expect_log_once 'args: "--experimental_tool_command_line='
+
+ # Structured command line. Expect the explicit flags to appear twice,
+ # in the canonical and original command lines
+ expect_log 'command_line_label: "original"'
+ expect_log 'command_line_label: "canonical"'
+ expect_log 'command_line_label: "tool"'
+
+ # Expect the actual tool command line flag to appear twice, because of the two
+ # bazel command lines that are reported
+ expect_log_n 'combined_form: "--experimental_tool_command_line=' 2
+ expect_log_n 'option_name: "experimental_tool_command_line"' 2
+ expect_log_n 'option_value: "foo bar"' 2
+
+ # Check the contents of the tool command line
+ expect_log_once 'chunk: "foo bar"'
+}
+
+
run_suite "Integration tests for the build event stream"