diff options
author | 2017-10-10 05:29:56 +0200 | |
---|---|---|
committer | 2017-10-10 11:24:42 +0200 | |
commit | ceb1013c1ca0238188e2714442fcfb2efb16bc6a (patch) | |
tree | 2cdd1a3a21e716a7653c8be61d39d8b2396c7bb0 /src/test | |
parent | 43edc92ac185ee2f1b8d0db31943ec1655b43434 (diff) |
Report the structured Bazel command line via the BEP.
This is part of the effort outlined in https://bazel.build/designs/2017/07/13/improved-command-line-reporting.html. The refactoring of the options parser is not yet complete, so we still do not have complete & correct information about the canonical command line. Where the information is blatantly incorrect, a best approximation was made, with comments and tests documenting the deficiencies.
Change the names of the initial CommandLine fields in the BEP to be explicitly identified as unstructured.
RELNOTES: None.
PiperOrigin-RevId: 171625377
Diffstat (limited to 'src/test')
4 files changed, 501 insertions, 13 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/BUILD b/src/test/java/com/google/devtools/build/lib/BUILD index 61903f6e5e..8a143410c5 100644 --- a/src/test/java/com/google/devtools/build/lib/BUILD +++ b/src/test/java/com/google/devtools/build/lib/BUILD @@ -1085,8 +1085,10 @@ java_test( "//src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs", "//src/main/java/com/google/devtools/common/options", "//src/main/java/com/google/devtools/common/options:invocation_policy", + "//src/main/protobuf:command_line_java_proto", "//src/main/protobuf:invocation_policy_java_proto", "//src/main/protobuf:test_status_java_proto", + "//src/test/java/com/google/devtools/common/options:testutils", "//third_party:guava", "//third_party:junit4", "//third_party:mockito", diff --git a/src/test/java/com/google/devtools/build/lib/runtime/CommandLineEventTest.java b/src/test/java/com/google/devtools/build/lib/runtime/CommandLineEventTest.java new file mode 100644 index 0000000000..be02e6dcba --- /dev/null +++ b/src/test/java/com/google/devtools/build/lib/runtime/CommandLineEventTest.java @@ -0,0 +1,428 @@ +// Copyright 2017 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.lib.runtime; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.common.collect.ImmutableList; +import com.google.devtools.build.lib.runtime.CommandLineEvent.CanonicalCommandLineEvent; +import com.google.devtools.build.lib.runtime.CommandLineEvent.OriginalCommandLineEvent; +import com.google.devtools.build.lib.runtime.proto.CommandLineOuterClass.CommandLine; +import com.google.devtools.build.lib.util.Pair; +import com.google.devtools.common.options.OptionPriority; +import com.google.devtools.common.options.OptionsParser; +import com.google.devtools.common.options.OptionsParsingException; +import com.google.devtools.common.options.TestOptions; +import java.util.Optional; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link CommandLineEvent}'s construction of the command lines. */ +@RunWith(JUnit4.class) +public class CommandLineEventTest { + + private void checkCommandLineSectionLabels(CommandLine line) { + assertThat(line.getSectionsCount()).isEqualTo(5); + + assertThat(line.getSections(0).getSectionLabel()).isEqualTo("executable"); + assertThat(line.getSections(1).getSectionLabel()).isEqualTo("startup options"); + assertThat(line.getSections(2).getSectionLabel()).isEqualTo("command"); + assertThat(line.getSections(3).getSectionLabel()).isEqualTo("command options"); + assertThat(line.getSections(4).getSectionLabel()).isEqualTo("residual"); + } + + @Test + public void testMostlyEmpty_OriginalCommandLine() { + OptionsParser fakeStartupOptions = + OptionsParser.newOptionsParser(BlazeServerStartupOptions.class); + OptionsParser fakeCommandOptions = OptionsParser.newOptionsParser(TestOptions.class); + + CommandLine line = + new OriginalCommandLineEvent( + "testblaze", + fakeStartupOptions, + "someCommandName", + fakeCommandOptions, + Optional.of(ImmutableList.of())) + .asStreamProto(null) + .getStructuredCommandLine(); + + assertThat(line).isNotNull(); + assertThat(line.getCommandLineLabel()).isEqualTo("original"); + checkCommandLineSectionLabels(line); + assertThat(line.getSections(0).getChunkList().getChunk(0)).isEqualTo("testblaze"); + assertThat(line.getSections(1).getOptionList().getOptionCount()).isEqualTo(0); + assertThat(line.getSections(2).getChunkList().getChunk(0)).isEqualTo("someCommandName"); + assertThat(line.getSections(3).getOptionList().getOptionCount()).isEqualTo(0); + assertThat(line.getSections(4).getChunkList().getChunkCount()).isEqualTo(0); + } + + @Test + public void testMostlyEmpty_CanonicalCommandLine() { + OptionsParser fakeStartupOptions = + OptionsParser.newOptionsParser(BlazeServerStartupOptions.class); + OptionsParser fakeCommandOptions = OptionsParser.newOptionsParser(TestOptions.class); + + CommandLine line = + new CanonicalCommandLineEvent( + "testblaze", fakeStartupOptions, "someCommandName", fakeCommandOptions) + .asStreamProto(null) + .getStructuredCommandLine(); + + assertThat(line).isNotNull(); + assertThat(line.getCommandLineLabel()).isEqualTo("canonical"); + checkCommandLineSectionLabels(line); + + assertThat(line.getSections(0).getChunkList().getChunk(0)).isEqualTo("testblaze"); + assertThat(line.getSections(1).getOptionList().getOptionCount()).isEqualTo(2); + assertThat(line.getSections(1).getOptionList().getOption(0).getCombinedForm()) + .isEqualTo("--nomaster_blazerc"); + assertThat(line.getSections(1).getOptionList().getOption(1).getCombinedForm()) + .isEqualTo("--blazerc=/dev/null"); + assertThat(line.getSections(2).getChunkList().getChunk(0)).isEqualTo("someCommandName"); + assertThat(line.getSections(3).getOptionList().getOptionCount()).isEqualTo(0); + assertThat(line.getSections(4).getChunkList().getChunkCount()).isEqualTo(0); + } + + @Test + public void testActiveBlazercs_OriginalCommandLine() throws OptionsParsingException { + OptionsParser fakeStartupOptions = + OptionsParser.newOptionsParser(BlazeServerStartupOptions.class); + fakeStartupOptions.parse( + "--blazerc=/some/path", "--master_blazerc", "--blazerc", "/some/other/path"); + OptionsParser fakeCommandOptions = OptionsParser.newOptionsParser(TestOptions.class); + + CommandLine line = + new OriginalCommandLineEvent( + "testblaze", + fakeStartupOptions, + "someCommandName", + fakeCommandOptions, + Optional.empty()) + .asStreamProto(null) + .getStructuredCommandLine(); + + assertThat(line).isNotNull(); + assertThat(line.getCommandLineLabel()).isEqualTo("original"); + checkCommandLineSectionLabels(line); + + // Expect the provided rc-related startup options are correctly listed + assertThat(line.getSections(0).getChunkList().getChunk(0)).isEqualTo("testblaze"); + assertThat(line.getSections(1).getOptionList().getOptionCount()).isEqualTo(3); + assertThat(line.getSections(1).getOptionList().getOption(0).getCombinedForm()) + .isEqualTo("--blazerc=/some/path"); + assertThat(line.getSections(1).getOptionList().getOption(1).getCombinedForm()) + .isEqualTo("--master_blazerc"); + assertThat(line.getSections(1).getOptionList().getOption(2).getCombinedForm()) + .isEqualTo("--blazerc /some/other/path"); + assertThat(line.getSections(2).getChunkList().getChunk(0)).isEqualTo("someCommandName"); + assertThat(line.getSections(3).getOptionList().getOptionCount()).isEqualTo(0); + assertThat(line.getSections(4).getChunkList().getChunkCount()).isEqualTo(0); + } + + @Test + public void testPassedInBlazercs_OriginalCommandLine() throws OptionsParsingException { + OptionsParser fakeStartupOptions = + OptionsParser.newOptionsParser(BlazeServerStartupOptions.class); + OptionsParser fakeCommandOptions = OptionsParser.newOptionsParser(TestOptions.class); + + CommandLine line = + new OriginalCommandLineEvent( + "testblaze", + fakeStartupOptions, + "someCommandName", + fakeCommandOptions, + Optional.of( + ImmutableList.of( + Pair.of("", "--blazerc=/some/path"), + Pair.of("", "--master_blazerc"), + Pair.of("", "--blazerc=/some/other/path"), + Pair.of("", "--invocation_policy=notARealPolicy")))) + .asStreamProto(null) + .getStructuredCommandLine(); + + assertThat(line).isNotNull(); + assertThat(line.getCommandLineLabel()).isEqualTo("original"); + checkCommandLineSectionLabels(line); + + // Expect the provided rc-related startup options are correctly listed + assertThat(line.getSections(0).getChunkList().getChunk(0)).isEqualTo("testblaze"); + assertThat(line.getSections(1).getOptionList().getOptionCount()).isEqualTo(4); + assertThat(line.getSections(1).getOptionList().getOption(0).getCombinedForm()) + .isEqualTo("--blazerc=/some/path"); + assertThat(line.getSections(1).getOptionList().getOption(1).getCombinedForm()) + .isEqualTo("--master_blazerc"); + assertThat(line.getSections(1).getOptionList().getOption(2).getCombinedForm()) + .isEqualTo("--blazerc=/some/other/path"); + assertThat(line.getSections(1).getOptionList().getOption(3).getCombinedForm()) + .isEqualTo("--invocation_policy=notARealPolicy"); + assertThat(line.getSections(2).getChunkList().getChunk(0)).isEqualTo("someCommandName"); + assertThat(line.getSections(3).getOptionList().getOptionCount()).isEqualTo(0); + assertThat(line.getSections(4).getChunkList().getChunkCount()).isEqualTo(0); + } + + @Test + public void testBlazercs_CanonicalCommandLine() throws OptionsParsingException { + OptionsParser fakeStartupOptions = + OptionsParser.newOptionsParser(BlazeServerStartupOptions.class); + fakeStartupOptions.parse( + "--blazerc=/some/path", "--master_blazerc", "--blazerc", "/some/other/path"); + OptionsParser fakeCommandOptions = OptionsParser.newOptionsParser(TestOptions.class); + + CommandLine line = + new CanonicalCommandLineEvent( + "testblaze", fakeStartupOptions, "someCommandName", fakeCommandOptions) + .asStreamProto(null) + .getStructuredCommandLine(); + + assertThat(line).isNotNull(); + assertThat(line.getCommandLineLabel()).isEqualTo("canonical"); + checkCommandLineSectionLabels(line); + + // Expect the provided rc-related startup options are removed and replaced with the + // rc-prevention options. + assertThat(line.getSections(0).getChunkList().getChunk(0)).isEqualTo("testblaze"); + assertThat(line.getSections(1).getOptionList().getOptionCount()).isEqualTo(2); + assertThat(line.getSections(1).getOptionList().getOption(0).getCombinedForm()) + .isEqualTo("--nomaster_blazerc"); + assertThat(line.getSections(1).getOptionList().getOption(1).getCombinedForm()) + .isEqualTo("--blazerc=/dev/null"); + assertThat(line.getSections(2).getChunkList().getChunk(0)).isEqualTo("someCommandName"); + assertThat(line.getSections(3).getOptionList().getOptionCount()).isEqualTo(0); + assertThat(line.getSections(4).getChunkList().getChunkCount()).isEqualTo(0); + } + + @Test + public void testOptionsAtVariousPriorities_OriginalCommandLine() throws OptionsParsingException { + OptionsParser fakeStartupOptions = + OptionsParser.newOptionsParser(BlazeServerStartupOptions.class); + OptionsParser fakeCommandOptions = OptionsParser.newOptionsParser(TestOptions.class); + fakeCommandOptions.parse( + OptionPriority.COMMAND_LINE, + "command line", + ImmutableList.of("--test_string=foo", "--test_multiple_string=bar")); + fakeCommandOptions.parse( + OptionPriority.INVOCATION_POLICY, + "fake invocation policy", + ImmutableList.of("--expanded_c=2")); + fakeCommandOptions.parse( + OptionPriority.RC_FILE, "fake rc file", ImmutableList.of("--test_multiple_string=baz")); + + CommandLine line = + new OriginalCommandLineEvent( + "testblaze", + fakeStartupOptions, + "someCommandName", + fakeCommandOptions, + Optional.of(ImmutableList.of())) + .asStreamProto(null) + .getStructuredCommandLine(); + + assertThat(line).isNotNull(); + assertThat(line.getCommandLineLabel()).isEqualTo("original"); + checkCommandLineSectionLabels(line); + + assertThat(line.getSections(0).getChunkList().getChunk(0)).isEqualTo("testblaze"); + assertThat(line.getSections(1).getOptionList().getOptionCount()).isEqualTo(0); + assertThat(line.getSections(2).getChunkList().getChunk(0)).isEqualTo("someCommandName"); + // Expect the rc file options and invocation policy options to not be listed with the explicit + // command line options. + assertThat(line.getSections(3).getOptionList().getOptionCount()).isEqualTo(2); + assertThat(line.getSections(3).getOptionList().getOption(0).getCombinedForm()) + .isEqualTo("--test_string=foo"); + assertThat(line.getSections(3).getOptionList().getOption(1).getCombinedForm()) + .isEqualTo("--test_multiple_string=bar"); + assertThat(line.getSections(4).getChunkList().getChunkCount()).isEqualTo(0); + } + + @Test + public void testOptionsAtVariousPriorities_CanonicalCommandLine() throws OptionsParsingException { + OptionsParser fakeStartupOptions = + OptionsParser.newOptionsParser(BlazeServerStartupOptions.class); + OptionsParser fakeCommandOptions = OptionsParser.newOptionsParser(TestOptions.class); + fakeCommandOptions.parse( + OptionPriority.COMMAND_LINE, + "command line", + ImmutableList.of("--test_string=foo", "--test_multiple_string=bar")); + fakeCommandOptions.parse( + OptionPriority.INVOCATION_POLICY, + "fake invocation policy", + ImmutableList.of("--expanded_c=2")); + fakeCommandOptions.parse( + OptionPriority.RC_FILE, "fake rc file", ImmutableList.of("--test_multiple_string=baz")); + + CommandLine line = + new CanonicalCommandLineEvent( + "testblaze", fakeStartupOptions, "someCommandName", fakeCommandOptions) + .asStreamProto(null) + .getStructuredCommandLine(); + + assertThat(line).isNotNull(); + assertThat(line.getCommandLineLabel()).isEqualTo("canonical"); + checkCommandLineSectionLabels(line); + + assertThat(line.getSections(0).getChunkList().getChunk(0)).isEqualTo("testblaze"); + assertThat(line.getSections(1).getOptionList().getOptionCount()).isEqualTo(2); + assertThat(line.getSections(2).getChunkList().getChunk(0)).isEqualTo("someCommandName"); + // In the canonical line, expect the rc option to show up before the higher priority options. + assertThat(line.getSections(3).getOptionList().getOptionCount()).isEqualTo(4); + assertThat(line.getSections(3).getOptionList().getOption(0).getCombinedForm()) + .isEqualTo("--test_multiple_string=baz"); + assertThat(line.getSections(3).getOptionList().getOption(1).getCombinedForm()) + .isEqualTo("--test_string=foo"); + assertThat(line.getSections(3).getOptionList().getOption(2).getCombinedForm()) + .isEqualTo("--test_multiple_string=bar"); + assertThat(line.getSections(3).getOptionList().getOption(3).getCombinedForm()) + .isEqualTo("--expanded_c=2"); + + assertThat(line.getSections(4).getChunkList().getChunkCount()).isEqualTo(0); + } + + @Test + public void testExpansionOption_OriginalCommandLine() throws OptionsParsingException { + OptionsParser fakeStartupOptions = + OptionsParser.newOptionsParser(BlazeServerStartupOptions.class); + OptionsParser fakeCommandOptions = OptionsParser.newOptionsParser(TestOptions.class); + fakeCommandOptions.parse( + OptionPriority.COMMAND_LINE, "command line", ImmutableList.of("--test_expansion")); + + CommandLine line = + new OriginalCommandLineEvent( + "testblaze", + fakeStartupOptions, + "someCommandName", + fakeCommandOptions, + Optional.of(ImmutableList.of())) + .asStreamProto(null) + .getStructuredCommandLine(); + + assertThat(line).isNotNull(); + assertThat(line.getCommandLineLabel()).isEqualTo("original"); + checkCommandLineSectionLabels(line); + + assertThat(line.getSections(0).getChunkList().getChunk(0)).isEqualTo("testblaze"); + assertThat(line.getSections(1).getOptionList().getOptionCount()).isEqualTo(0); + assertThat(line.getSections(2).getChunkList().getChunk(0)).isEqualTo("someCommandName"); + // Expect the rc file option to not be listed with the explicit command line options. + assertThat(line.getSections(3).getOptionList().getOptionCount()).isEqualTo(1); + assertThat(line.getSections(3).getOptionList().getOption(0).getCombinedForm()) + .isEqualTo("--test_expansion"); + assertThat(line.getSections(4).getChunkList().getChunkCount()).isEqualTo(0); + } + + @Test + public void testExpansionOption_CanonicalCommandLine() throws OptionsParsingException { + OptionsParser fakeStartupOptions = + OptionsParser.newOptionsParser(BlazeServerStartupOptions.class); + OptionsParser fakeCommandOptions = OptionsParser.newOptionsParser(TestOptions.class); + fakeCommandOptions.parse( + OptionPriority.COMMAND_LINE, "command line", ImmutableList.of("--test_expansion")); + + CommandLine line = + new CanonicalCommandLineEvent( + "testblaze", fakeStartupOptions, "someCommandName", fakeCommandOptions) + .asStreamProto(null) + .getStructuredCommandLine(); + + assertThat(line).isNotNull(); + assertThat(line.getCommandLineLabel()).isEqualTo("canonical"); + checkCommandLineSectionLabels(line); + + assertThat(line.getSections(0).getChunkList().getChunk(0)).isEqualTo("testblaze"); + assertThat(line.getSections(1).getOptionList().getOptionCount()).isEqualTo(2); + assertThat(line.getSections(2).getChunkList().getChunk(0)).isEqualTo("someCommandName"); + + // TODO(b/19881919) Expansion options shouldn't be listed along with their expansions, this + // could cause duplicate values for repeatable flags. There should be 4 flags here, without + // test_expansion listed. + assertThat(line.getSections(3).getOptionList().getOptionCount()).isEqualTo(5); + assertThat(line.getSections(3).getOptionList().getOption(0).getCombinedForm()) + .isEqualTo("--test_expansion"); + assertThat(line.getSections(3).getOptionList().getOption(1).getCombinedForm()) + .isEqualTo("--noexpanded_a"); + assertThat(line.getSections(3).getOptionList().getOption(2).getCombinedForm()) + .isEqualTo("--expanded_b=false"); + assertThat(line.getSections(3).getOptionList().getOption(3).getCombinedForm()) + .isEqualTo("--expanded_c 42"); + assertThat(line.getSections(3).getOptionList().getOption(4).getCombinedForm()) + .isEqualTo("--expanded_d bar"); + assertThat(line.getSections(4).getChunkList().getChunkCount()).isEqualTo(0); + } + + @Test + public void testOptionWithImplicitRequirement_OriginalCommandLine() + throws OptionsParsingException { + OptionsParser fakeStartupOptions = + OptionsParser.newOptionsParser(BlazeServerStartupOptions.class); + OptionsParser fakeCommandOptions = OptionsParser.newOptionsParser(TestOptions.class); + fakeCommandOptions.parse( + OptionPriority.COMMAND_LINE, + "command line", + ImmutableList.of("--test_implicit_requirement=foo")); + + CommandLine line = + new OriginalCommandLineEvent( + "testblaze", + fakeStartupOptions, + "someCommandName", + fakeCommandOptions, + Optional.of(ImmutableList.of())) + .asStreamProto(null) + .getStructuredCommandLine(); + + assertThat(line).isNotNull(); + assertThat(line.getCommandLineLabel()).isEqualTo("original"); + checkCommandLineSectionLabels(line); + + assertThat(line.getSections(0).getChunkList().getChunk(0)).isEqualTo("testblaze"); + assertThat(line.getSections(1).getOptionList().getOptionCount()).isEqualTo(0); + assertThat(line.getSections(2).getChunkList().getChunk(0)).isEqualTo("someCommandName"); + assertThat(line.getSections(3).getOptionList().getOptionCount()).isEqualTo(1); + assertThat(line.getSections(3).getOptionList().getOption(0).getCombinedForm()) + .isEqualTo("--test_implicit_requirement=foo"); + assertThat(line.getSections(4).getChunkList().getChunkCount()).isEqualTo(0); + } + + @Test + public void testOptionWithImplicitRequirement_CanonicalCommandLine() + throws OptionsParsingException { + OptionsParser fakeStartupOptions = + OptionsParser.newOptionsParser(BlazeServerStartupOptions.class); + OptionsParser fakeCommandOptions = OptionsParser.newOptionsParser(TestOptions.class); + fakeCommandOptions.parse( + OptionPriority.COMMAND_LINE, + "command line", + ImmutableList.of("--test_implicit_requirement=foo")); + + CommandLine line = + new CanonicalCommandLineEvent( + "testblaze", fakeStartupOptions, "someCommandName", fakeCommandOptions) + .asStreamProto(null) + .getStructuredCommandLine(); + + assertThat(line).isNotNull(); + assertThat(line.getCommandLineLabel()).isEqualTo("canonical"); + checkCommandLineSectionLabels(line); + + // Unlike expansion flags, implicit requirements are not listed separately. + assertThat(line.getSections(0).getChunkList().getChunk(0)).isEqualTo("testblaze"); + assertThat(line.getSections(1).getOptionList().getOptionCount()).isEqualTo(2); + assertThat(line.getSections(2).getChunkList().getChunk(0)).isEqualTo("someCommandName"); + assertThat(line.getSections(3).getOptionList().getOptionCount()).isEqualTo(1); + assertThat(line.getSections(3).getOptionList().getOption(0).getCombinedForm()) + .isEqualTo("--test_implicit_requirement=foo"); + assertThat(line.getSections(4).getChunkList().getChunkCount()).isEqualTo(0); + } +} diff --git a/src/test/java/com/google/devtools/common/options/BUILD b/src/test/java/com/google/devtools/common/options/BUILD index 10eda9581c..fbb837eae9 100644 --- a/src/test/java/com/google/devtools/common/options/BUILD +++ b/src/test/java/com/google/devtools/common/options/BUILD @@ -4,11 +4,38 @@ filegroup( visibility = ["//src:__pkg__"], ) +java_library( + name = "testutils", + testonly = 1, + srcs = [ + "InvocationPolicyEnforcerTestBase.java", + "TestOptions.java", + ], + visibility = [ + "//src/test/java:__subpackages__", + ], + deps = [ + "//src/main/java/com/google/devtools/build/lib:build-base", + "//src/main/java/com/google/devtools/common/options", + "//src/main/java/com/google/devtools/common/options:invocation_policy", + "//src/main/protobuf:invocation_policy_java_proto", + "//third_party:guava", + "//third_party:junit4", + ], +) + java_test( name = "options_test", - srcs = glob(["*.java"]), + srcs = glob( + ["*.java"], + exclude = [ + "TestOptions.java", + "InvocationPolicyEnforcerTestBase.java", + ], + ), test_class = "com.google.devtools.common.options.AllTests", deps = [ + ":testutils", "//src/main/java/com/google/devtools/build/lib:build-base", "//src/main/java/com/google/devtools/build/lib:util", "//src/main/java/com/google/devtools/common/options", diff --git a/src/test/shell/integration/build_event_stream_test.sh b/src/test/shell/integration/build_event_stream_test.sh index ec59bc3ed1..ad0864015c 100755 --- a/src/test/shell/integration/build_event_stream_test.sh +++ b/src/test/shell/integration/build_event_stream_test.sh @@ -192,30 +192,62 @@ function test_basic() { # Basic properties of the event stream # - a completed target explicity requested should be reported # - after success the stream should close naturally, without any - # reports about aborted events. - # - the command line is reported + # reports about aborted events + # - the command line is reported in structured and unstructured form # - the target_kind is reported # - for single-configuration builds, there is precisely one configuration # event reported; also make variables are shown - bazel test --build_event_text_file=$TEST_log --tool_tag=MyFancyTool pkg:true \ + bazel test -k --build_event_text_file=$TEST_log --tool_tag=MyFancyTool pkg:true \ || fail "bazel test failed" expect_log 'pkg:true' # Command line - expect_log 'args: "test"' - expect_log 'args: "--build_event_text_file=' - expect_log 'args: "pkg:true"' - # Options parsed - expect_log 'tool_tag: "MyFancyTool"' + expect_log_once 'args: "test"' + expect_log_once 'args: "--build_event_text_file=' + expect_log_once 'args: "-k"' + expect_log_once 'args: "--tool_tag=MyFancyTool"' + expect_log_once 'args: "pkg:true"' + + # Options parsed. Since cmd_line lines are a substring of the equivalent + # explicit_cmd_line lines, we expect 2 instances for these. + expect_log_n 'cmd_line: "--tool_tag=MyFancyTool"' 2 + expect_log_n 'cmd_line: "--keep_going"' 2 + expect_log_once 'explicit_cmd_line: "--keep_going"' + expect_log_once 'explicit_cmd_line: "--tool_tag=MyFancyTool"' + expect_log_once 'tool_tag: "MyFancyTool"' + + # 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_n 'combined_form: "-k"' 2 + expect_log_n 'option_name: "keep_going"' 2 + expect_log 'option_value: "1"' # too vague to count. + + expect_log_n 'combined_form: "--tool_tag=MyFancyTool"' 2 + expect_log_n 'option_name: "tool_tag"' 2 + expect_log_n 'option_value: "MyFancyTool"' 2 + + expect_log_n "combined_form: \"--build_event_text_file=${TEST_log}\"" 2 + expect_log_n 'option_name: "build_event_text_file"' 2 + expect_log_n "option_value: \"${TEST_log}\"" 2 + + expect_log_n 'chunk: "test"' 2 + expect_log_n 'chunk: "pkg:true"' 2 + # Build Finished expect_log 'build_finished' expect_log 'SUCCESS' expect_log 'finish_time' expect_not_log 'aborted' - # target kind for the sh_test + + # Target kind for the sh_test expect_log 'target_kind:.*sh' - # test size should be reported + + # Test size should be reported expect_log 'test_size: SMALL' - # configuration reported with make variables + + # Configuration reported with make variables expect_log_once '^configuration ' expect_log 'key: "TARGET_CPU"' } @@ -563,7 +595,6 @@ function test_loading_failure() { # being expanded. (bazel build --build_event_text_file=$TEST_log \ //does/not/exist && fail "build failure expected") || true - expect_log_once '^progress ' expect_log_once 'aborted' expect_log_once 'reason: LOADING_FAILURE' expect_log 'description.*BUILD file not found on package path' |