From 654c77c603c039142d8b257f47bdaf14ac507c47 Mon Sep 17 00:00:00 2001 From: ccalvarin Date: Thu, 14 Jun 2018 09:56:29 -0700 Subject: Remove fixed point config expansion. Deprecates the flag, though it continues to exist as a no-op so that users get a warning before errors. RELNOTES: --noexpand_configs_in_place is deprecated. PiperOrigin-RevId: 200572053 --- .../build/lib/runtime/BlazeOptionHandlerTest.java | 699 ++------------------- 1 file changed, 55 insertions(+), 644 deletions(-) (limited to 'src/test/java/com/google') diff --git a/src/test/java/com/google/devtools/build/lib/runtime/BlazeOptionHandlerTest.java b/src/test/java/com/google/devtools/build/lib/runtime/BlazeOptionHandlerTest.java index 33b8acb10c..e639979c0a 100644 --- a/src/test/java/com/google/devtools/build/lib/runtime/BlazeOptionHandlerTest.java +++ b/src/test/java/com/google/devtools/build/lib/runtime/BlazeOptionHandlerTest.java @@ -84,30 +84,15 @@ public class BlazeOptionHandlerTest { /* defaultSystemJavabase= */ null, productName); runtime.initWorkspace(directories, /*binTools=*/ null); - } - - private void makeFixedPointExpandingConfigOptionHandler() { - optionHandler = - BlazeOptionHandler.getHandler( - runtime, - runtime.getWorkspace(), - new C0Command(), - C0Command.class.getAnnotation(Command.class), - parser, - InvocationPolicy.getDefaultInstance(), - false); - } - private void makeInPlaceExpandingConfigOptionHandler() { optionHandler = - BlazeOptionHandler.getHandler( + new BlazeOptionHandler( runtime, runtime.getWorkspace(), new C0Command(), C0Command.class.getAnnotation(Command.class), parser, - InvocationPolicy.getDefaultInstance(), - true); + InvocationPolicy.getDefaultInstance()); } @Command( @@ -169,7 +154,8 @@ public class BlazeOptionHandlerTest { return structuredArgs; } - private void testStructureRcOptionsAndConfigs_argumentless() throws Exception { + @Test + public void testStructureRcOptionsAndConfigs_argumentless_inPlace() throws Exception { ListMultimap structuredRc = BlazeOptionHandler.structureRcOptionsAndConfigs( eventHandler, @@ -181,18 +167,7 @@ public class BlazeOptionHandlerTest { } @Test - public void testStructureRcOptionsAndConfigs_argumentless_fixedPoint() throws Exception { - makeFixedPointExpandingConfigOptionHandler(); - testStructureRcOptionsAndConfigs_argumentless(); - } - - @Test - public void testStructureRcOptionsAndConfigs_argumentless_inPlace() throws Exception { - makeInPlaceExpandingConfigOptionHandler(); - testStructureRcOptionsAndConfigs_argumentless(); - } - - private void testStructureRcOptionsAndConfigs_configOnly() throws Exception { + public void testStructureRcOptionsAndConfigs_configOnly_inPlace() throws Exception { BlazeOptionHandler.structureRcOptionsAndConfigs( eventHandler, Arrays.asList("rc1", "rc2"), @@ -202,18 +177,7 @@ public class BlazeOptionHandlerTest { } @Test - public void testStructureRcOptionsAndConfigs_configOnly_fixedPoint() throws Exception { - makeFixedPointExpandingConfigOptionHandler(); - testStructureRcOptionsAndConfigs_configOnly(); - } - - @Test - public void testStructureRcOptionsAndConfigs_configOnly_inPlace() throws Exception { - makeInPlaceExpandingConfigOptionHandler(); - testStructureRcOptionsAndConfigs_configOnly(); - } - - private void testStructureRcOptionsAndConfigs_invalidCommand() throws Exception { + public void testStructureRcOptionsAndConfigs_invalidCommand_inPlace() throws Exception { BlazeOptionHandler.structureRcOptionsAndConfigs( eventHandler, Arrays.asList("rc1", "rc2"), @@ -225,18 +189,7 @@ public class BlazeOptionHandlerTest { } @Test - public void testStructureRcOptionsAndConfigs_invalidCommand_fixedPoint() throws Exception { - makeFixedPointExpandingConfigOptionHandler(); - testStructureRcOptionsAndConfigs_invalidCommand(); - } - - @Test - public void testStructureRcOptionsAndConfigs_invalidCommand_inPlace() throws Exception { - makeInPlaceExpandingConfigOptionHandler(); - testStructureRcOptionsAndConfigs_invalidCommand(); - } - - private void testStructureRcOptionsAndConfigs_twoRcs() throws Exception { + public void testStructureRcOptionsAndConfigs_twoRcs_inPlace() throws Exception { ListMultimap structuredRc = BlazeOptionHandler.structureRcOptionsAndConfigs( eventHandler, @@ -255,18 +208,7 @@ public class BlazeOptionHandlerTest { } @Test - public void testStructureRcOptionsAndConfigs_twoRcs_fixedPoint() throws Exception { - makeFixedPointExpandingConfigOptionHandler(); - testStructureRcOptionsAndConfigs_twoRcs(); - } - - @Test - public void testStructureRcOptionsAndConfigs_twoRcs_inPlace() throws Exception { - makeInPlaceExpandingConfigOptionHandler(); - testStructureRcOptionsAndConfigs_twoRcs(); - } - - private void testStructureRcOptionsAndConfigs_importedRcs() throws Exception { + public void testStructureRcOptionsAndConfigs_importedRcs_inPlace() throws Exception { ListMultimap structuredRc = BlazeOptionHandler.structureRcOptionsAndConfigs( eventHandler, @@ -285,18 +227,6 @@ public class BlazeOptionHandlerTest { assertThat(eventHandler.isEmpty()).isTrue(); } - @Test - public void testStructureRcOptionsAndConfigs_importedRcs_fixedPoint() throws Exception { - makeFixedPointExpandingConfigOptionHandler(); - testStructureRcOptionsAndConfigs_importedRcs(); - } - - @Test - public void testStructureRcOptionsAndConfigs_importedRcs_inPlace() throws Exception { - makeInPlaceExpandingConfigOptionHandler(); - testStructureRcOptionsAndConfigs_importedRcs(); - } - private void testStructureRcOptionsAndConfigs_badOverrideIndex() throws Exception { ListMultimap structuredRc = BlazeOptionHandler.structureRcOptionsAndConfigs( @@ -320,15 +250,9 @@ public class BlazeOptionHandlerTest { Event.warn("inconsistency in generated command line args. Ignoring bogus argument\n")); } - @Test - public void testStructureRcOptionsAndConfigs_badOverrideIndex_fixedPoint() throws Exception { - makeFixedPointExpandingConfigOptionHandler(); - testStructureRcOptionsAndConfigs_badOverrideIndex(); - } - @Test public void testStructureRcOptionsAndConfigs_badOverrideIndex_inPlace() throws Exception { - makeInPlaceExpandingConfigOptionHandler(); + testStructureRcOptionsAndConfigs_badOverrideIndex(); } @@ -338,15 +262,9 @@ public class BlazeOptionHandlerTest { assertThat(parser.getResidue()).isEmpty(); } - @Test - public void testParseRcOptions_empty_fixedPoint() throws Exception { - makeFixedPointExpandingConfigOptionHandler(); - testParseRcOptions_empty(); - } - @Test public void testParseRcOptions_empty_inPlace() throws Exception { - makeInPlaceExpandingConfigOptionHandler(); + testParseRcOptions_empty(); } @@ -356,15 +274,9 @@ public class BlazeOptionHandlerTest { assertThat(parser.getResidue()).containsExactly("c", "a", "d", "e").inOrder(); } - @Test - public void testParseRcOptions_flatRcs_residue_fixedPoint() throws Exception { - makeFixedPointExpandingConfigOptionHandler(); - testParseRcOptions_flatRcs_residue(); - } - @Test public void testParseRcOptions_flatRcs_residue_inPlace() throws Exception { - makeInPlaceExpandingConfigOptionHandler(); + testParseRcOptions_flatRcs_residue(); } @@ -376,15 +288,9 @@ public class BlazeOptionHandlerTest { assertThat(options.testMultipleString).containsExactly("common", "foo", "bar").inOrder(); } - @Test - public void testParseRcOptions_flatRcs_flags_fixedPoint() throws Exception { - makeFixedPointExpandingConfigOptionHandler(); - testParseRcOptions_flatRcs_flags(); - } - @Test public void testParseRcOptions_flatRcs_flags_inPlace() throws Exception { - makeInPlaceExpandingConfigOptionHandler(); + testParseRcOptions_flatRcs_flags(); } @@ -394,15 +300,9 @@ public class BlazeOptionHandlerTest { assertThat(parser.getResidue()).containsExactly("c", "a", "d", "e", "h").inOrder(); } - @Test - public void testParseRcOptions_importedRcs_residue_fixedPoint() throws Exception { - makeFixedPointExpandingConfigOptionHandler(); - testParseRcOptions_importedRcs_residue(); - } - @Test public void testParseRcOptions_importedRcs_residue_inPlace() throws Exception { - makeInPlaceExpandingConfigOptionHandler(); + testParseRcOptions_importedRcs_residue(); } @@ -411,15 +311,9 @@ public class BlazeOptionHandlerTest { assertThat(parser.getResidue()).isEmpty(); } - @Test - public void testExpandConfigOptions_configless_fixedPoint() throws Exception { - makeFixedPointExpandingConfigOptionHandler(); - testExpandConfigOptions_configless(); - } - @Test public void testExpandConfigOptions_configless_inPlace() throws Exception { - makeInPlaceExpandingConfigOptionHandler(); + testExpandConfigOptions_configless(); } @@ -431,15 +325,9 @@ public class BlazeOptionHandlerTest { .containsExactly("Found applicable config definition c0:config in file rc1: b"); } - @Test - public void testExpandConfigOptions_withConfig_fixedPoint() throws Exception { - makeFixedPointExpandingConfigOptionHandler(); - testExpandConfigOptions_withConfig(); - } - @Test public void testExpandConfigOptions_withConfig_inPlace() throws Exception { - makeInPlaceExpandingConfigOptionHandler(); + testExpandConfigOptions_withConfig(); } @@ -450,23 +338,9 @@ public class BlazeOptionHandlerTest { assertThat(optionHandler.getRcfileNotes()).isEmpty(); } - @Test - public void testExpandConfigOptions_withConfigForUnapplicableCommand_fixedPoint() - throws Exception { - makeFixedPointExpandingConfigOptionHandler(); - try { - testExpandConfigOptions_withConfigForUnapplicableCommand(); - fail(); - } catch (OptionsParsingException e) { - assertThat(e) - .hasMessageThat() - .contains("Config values are not defined in any .rc file: other"); - } - } - @Test public void testExpandConfigOptions_withConfigForUnapplicableCommand_inPlace() throws Exception { - makeInPlaceExpandingConfigOptionHandler(); + try { testExpandConfigOptions_withConfigForUnapplicableCommand(); fail(); @@ -481,19 +355,10 @@ public class BlazeOptionHandlerTest { optionHandler.expandConfigOptions(eventHandler, structuredArgsFrom2SimpleRcsWithOnlyResidue()); } - @Test - public void testExpandConfigOptions_withConfigForUnapplicableCommand_allowUndefined_fixedPoint() - throws Exception { - makeFixedPointExpandingConfigOptionHandler(); - testExpandConfigOptions_withConfigForUnapplicableCommand_allowUndefined(); - assertThat(eventHandler.getEvents()) - .contains(Event.warn("Config values are not defined in any .rc file: other")); - } - @Test public void testExpandConfigOptions_withConfigForUnapplicableCommand_allowUndefined_inPlace() throws Exception { - makeInPlaceExpandingConfigOptionHandler(); + testExpandConfigOptions_withConfigForUnapplicableCommand_allowUndefined(); assertThat(eventHandler.getEvents()) .contains(Event.warn("Config value other is not defined in any .rc file")); @@ -506,17 +371,9 @@ public class BlazeOptionHandlerTest { assertThat(optionHandler.getRcfileNotes()).isEmpty(); } - @Test - public void testAllowUndefinedConfig_fixedPoint() throws Exception { - makeFixedPointExpandingConfigOptionHandler(); - testAllowUndefinedConfig(); - assertThat(eventHandler.getEvents()) - .contains(Event.warn("Config values are not defined in any .rc file: invalid")); - } - @Test public void testAllowUndefinedConfig_inPlace() throws Exception { - makeInPlaceExpandingConfigOptionHandler(); + testAllowUndefinedConfig(); assertThat(eventHandler.getEvents()) .contains(Event.warn("Config value invalid is not defined in any .rc file")); @@ -527,22 +384,9 @@ public class BlazeOptionHandlerTest { optionHandler.expandConfigOptions(eventHandler, ArrayListMultimap.create()); } - @Test - public void testNoAllowUndefinedConfig_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - try { - testUndefinedConfig(); - fail(); - } catch (OptionsParsingException e) { - assertThat(e) - .hasMessageThat() - .contains("Config values are not defined in any .rc file: invalid"); - } - } - @Test public void testNoAllowUndefinedConfig_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); + try { testUndefinedConfig(); fail(); @@ -560,15 +404,9 @@ public class BlazeOptionHandlerTest { assertThat(optionHandler.getRcfileNotes()).isEmpty(); } - @Test - public void testParseOptions_argless_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testParseOptions_argless(); - } - @Test public void testParseOptions_argless_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); + testParseOptions_argless(); } @@ -579,15 +417,9 @@ public class BlazeOptionHandlerTest { assertThat(optionHandler.getRcfileNotes()).isEmpty(); } - @Test - public void testParseOptions_residue_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testParseOptions_residue(); - } - @Test public void testParseOptions_residue_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); + testParseOptions_residue(); } @@ -602,15 +434,9 @@ public class BlazeOptionHandlerTest { assertThat(options.testMultipleString).containsExactly("explicit"); } - @Test - public void testParseOptions_explicitOption_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testParseOptions_explicitOption(); - } - @Test public void testParseOptions_explicitOption_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); + testParseOptions_explicitOption(); } @@ -634,15 +460,9 @@ public class BlazeOptionHandlerTest { assertThat(options.testMultipleString).containsExactly("rc_a", "rc_b"); } - @Test - public void testParseOptions_rcOption_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testParseOptions_rcOption(); - } - @Test public void testParseOptions_rcOption_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); + testParseOptions_rcOption(); } @@ -671,19 +491,14 @@ public class BlazeOptionHandlerTest { assertThat(options.testMultipleString).containsExactly("rc1_a", "rc2", "rc1_b").inOrder(); } - @Test - public void testParseOptions_multipleRcs_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testParseOptions_multipleRcs(); - } - @Test public void testParseOptions_multipleRcs_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); + testParseOptions_multipleRcs(); } - private void testParseOptions_multipleRcsWithMultipleCommands() { + @Test + public void testParseOptions_multipleRcsWithMultipleCommands_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -717,18 +532,7 @@ public class BlazeOptionHandlerTest { } @Test - public void testParseOptions_multipleRcsWithMultipleCommands_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testParseOptions_multipleRcsWithMultipleCommands(); - } - - @Test - public void testParseOptions_multipleRcsWithMultipleCommands_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - testParseOptions_multipleRcsWithMultipleCommands(); - } - - private void testParseOptions_rcOptionAndExplicit() { + public void testParseOptions_rcOptionAndExplicit_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -748,18 +552,7 @@ public class BlazeOptionHandlerTest { } @Test - public void testParseOptions_rcOptionAndExplicit_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testParseOptions_rcOptionAndExplicit(); - } - - @Test - public void testParseOptions_rcOptionAndExplicit_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - testParseOptions_rcOptionAndExplicit(); - } - - private void testParseOptions_multiCommandRcOptionAndExplicit() { + public void testParseOptions_multiCommandRcOptionAndExplicit_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -785,18 +578,7 @@ public class BlazeOptionHandlerTest { } @Test - public void testParseOptions_multiCommandRcOptionAndExplicit_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testParseOptions_multiCommandRcOptionAndExplicit(); - } - - @Test - public void testParseOptions_multiCommandRcOptionAndExplicit_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - testParseOptions_multiCommandRcOptionAndExplicit(); - } - - private void testParseOptions_multipleRcsWithMultipleCommandsPlusExplicitOption() { + public void testParseOptions_multipleRcsWithMultipleCommandsPlusExplicitOption_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -831,18 +613,7 @@ public class BlazeOptionHandlerTest { } @Test - public void testParseOptions_multipleRcsWithMultipleCommandsPlusExplicitOption_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testParseOptions_multipleRcsWithMultipleCommandsPlusExplicitOption(); - } - - @Test - public void testParseOptions_multipleRcsWithMultipleCommandsPlusExplicitOption_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - testParseOptions_multipleRcsWithMultipleCommandsPlusExplicitOption(); - } - - private void testParseOptions_explicitConfig() { + public void testParseOptions_explicitConfig_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -860,24 +631,6 @@ public class BlazeOptionHandlerTest { + " 'c0' options: --test_multiple_string=rc", "Found applicable config definition c0:conf in file /somewhere/.blazerc: " + "--test_multiple_string=config"); - } - - @Test - public void testParseOptions_explicitConfig_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testParseOptions_explicitConfig(); - - // "config" is lower priority (occurs earlier in the list) than "explicit" in the fix-point - // expansion, despite --config=conf occurring later. - TestOptions options = parser.getOptions(TestOptions.class); - assertThat(options).isNotNull(); - assertThat(options.testMultipleString).containsExactly("rc", "config", "explicit").inOrder(); - } - - @Test - public void testParseOptions_explicitConfig_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - testParseOptions_explicitConfig(); // "config" is expanded from --config=conf, which occurs last. TestOptions options = parser.getOptions(TestOptions.class); @@ -885,7 +638,8 @@ public class BlazeOptionHandlerTest { assertThat(options.testMultipleString).containsExactly("rc", "explicit", "config").inOrder(); } - private void testParseOptions_rcSpecifiedConfig() { + @Test + public void testParseOptions_rcSpecifiedConfig_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -903,24 +657,6 @@ public class BlazeOptionHandlerTest { + " 'c0' options: --config=conf --test_multiple_string=rc", "Found applicable config definition c0:conf in file /somewhere/.blazerc: " + "--test_multiple_string=config"); - } - - @Test - public void testParseOptions_rcSpecifiedConfig_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testParseOptions_rcSpecifiedConfig(); - - // "config" is higher priority (occurs later in the list) than "rc" in the fix-point - // expansion, despite --config=conf occurring before the explicit mention of "rc". - TestOptions options = parser.getOptions(TestOptions.class); - assertThat(options).isNotNull(); - assertThat(options.testMultipleString).containsExactly("rc", "config", "explicit").inOrder(); - } - - @Test - public void testParseOptions_rcSpecifiedConfig_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - testParseOptions_rcSpecifiedConfig(); // "config" is expanded from --config=conf, which occurs before the explicit mention of "rc". TestOptions options = parser.getOptions(TestOptions.class); @@ -928,7 +664,8 @@ public class BlazeOptionHandlerTest { assertThat(options.testMultipleString).containsExactly("config", "rc", "explicit").inOrder(); } - private void testParseOptions_recursiveConfig() { + @Test + public void testParseOptions_recursiveConfig_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -953,25 +690,6 @@ public class BlazeOptionHandlerTest { + "--test_multiple_string=othercommon", "Found applicable config definition c0:other in file /somewhere/.blazerc: " + "--test_multiple_string=other"); - } - - @Test - public void testParseOptions_recursiveConfig_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testParseOptions_recursiveConfig(); - - // The 2nd config, --config=other, is expanded after the config that added it. - TestOptions options = parser.getOptions(TestOptions.class); - assertThat(options).isNotNull(); - assertThat(options.testMultipleString) - .containsExactly("rc", "config1", "othercommon", "other", "explicit") - .inOrder(); - } - - @Test - public void testParseOptions_recursiveConfig_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - testParseOptions_recursiveConfig(); // The 2nd config, --config=other, is added by --config=conf after conf adds its own value. TestOptions options = parser.getOptions(TestOptions.class); @@ -981,7 +699,8 @@ public class BlazeOptionHandlerTest { .inOrder(); } - private void testParseOptions_recursiveConfigWithDifferentTokens() { + @Test + public void testParseOptions_recursiveConfigWithDifferentTokens_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -993,33 +712,7 @@ public class BlazeOptionHandlerTest { "--rc_source=/somewhere/.blazerc", "--config=conf"), eventHandler); - } - - @Test - public void testParseOptions_recursiveConfigWithDifferentTokens_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testParseOptions_recursiveConfigWithDifferentTokens(); - assertThat(eventHandler.getEvents()).isEmpty(); - assertThat(parser.getResidue()).isEmpty(); - assertThat(optionHandler.getRcfileNotes()) - .containsExactly( - "Reading rc options for 'c0' from /somewhere/.blazerc:\n" - + " 'c0' options: --test_multiple_string=rc", - "Found applicable config definition c0:conf in file /somewhere/.blazerc: " - + "--test_multiple_string=config1 --config other", - "Found applicable config definition c0:other in file /somewhere/.blazerc: " - + "--test_multiple_string=other"); - // The 2nd config, --config other, is expanded after the config that added it. - TestOptions options = parser.getOptions(TestOptions.class); - assertThat(options).isNotNull(); - assertThat(options.testMultipleString).containsExactly("rc", "config1", "other").inOrder(); - } - - @Test - public void testParseOptions_recursiveConfigWithDifferentTokens_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - testParseOptions_recursiveConfigWithDifferentTokens(); assertThat(eventHandler.getEvents()) .containsExactly( Event.error( @@ -1029,7 +722,8 @@ public class BlazeOptionHandlerTest { + "separate token, such as in the form '--config value'.")); } - private void parseComplexConfigOrderCommandLine() { + @Test + public void testParseOptions_complexConfigOrder_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -1052,51 +746,6 @@ public class BlazeOptionHandlerTest { eventHandler); assertThat(eventHandler.getEvents()).isEmpty(); assertThat(parser.getResidue()).isEmpty(); - } - - @Test - public void testParseOptions_complexConfigOrder_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - parseComplexConfigOrderCommandLine(); - assertThat(optionHandler.getRcfileNotes()) - .containsExactly( - "Reading rc options for 'c0' from /somewhere/.blazerc:\n 'c0' options: " - + "--test_multiple_string=rc1 --config=foo --test_multiple_string=rc2", - "Found applicable config definition common:foo in file /somewhere/.blazerc: " - + "--test_multiple_string=foo1 --config=bar --test_multiple_string=foo2", - "Found applicable config definition common:baz in file /somewhere/.blazerc: " - + "--test_multiple_string=baz1", - "Found applicable config definition c0:foo in file /somewhere/.blazerc: " - + "--test_multiple_string=foo3 --test_multiple_string=foo4", - "Found applicable config definition c0:baz in file /somewhere/.blazerc: " - + "--test_multiple_string=baz2", - "Found applicable config definition common:bar in file /somewhere/.blazerc: " - + "--test_multiple_string=bar1", - "Found applicable config definition c0:bar in file /somewhere/.blazerc: " - + "--test_multiple_string=bar2"); - TestOptions options = parser.getOptions(TestOptions.class); - assertThat(options).isNotNull(); - assertThat(options.testMultipleString) - .containsExactly( - "rc1", - "rc2", - "foo1", - "foo2", - "baz1", - "foo3", - "foo4", - "baz2", - "bar1", - "bar2", - "explicit1", - "explicit2") - .inOrder(); - } - - @Test - public void testParseOptions_complexConfigOrder_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - parseComplexConfigOrderCommandLine(); assertThat(optionHandler.getRcfileNotes()) .containsExactly( "Reading rc options for 'c0' from /somewhere/.blazerc:\n 'c0' options: " @@ -1132,7 +781,8 @@ public class BlazeOptionHandlerTest { .inOrder(); } - private void parseConfigDoubleRecursionCommandLine() { + @Test + public void testParseOptions_repeatSubConfig_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -1146,34 +796,6 @@ public class BlazeOptionHandlerTest { "--test_multiple_string=explicit"), eventHandler); assertThat(parser.getResidue()).isEmpty(); - } - - @Test - public void testParseOptions_repeatSubConfig_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - parseConfigDoubleRecursionCommandLine(); - assertThat(eventHandler.getEvents()).isEmpty(); - assertThat(optionHandler.getRcfileNotes()) - .containsExactly( - "Reading rc options for 'c0' from /somewhere/.blazerc:\n" - + " 'c0' options: --config=foo --test_multiple_string=rc", - "Found applicable config definition c0:foo in file /somewhere/.blazerc: " - + "--test_multiple_string=foo --config=bar --config=bar", - "Found applicable config definition c0:bar in file /somewhere/.blazerc: " - + "--test_multiple_string=bar"); - TestOptions options = parser.getOptions(TestOptions.class); - assertThat(options).isNotNull(); - // Bar is not repeated, it was already expanded once and the fixed point expansion - // does not attempt to expand configs a second time. - assertThat(options.testMultipleString) - .containsExactly("rc", "foo", "bar", "explicit") - .inOrder(); - } - - @Test - public void testParseOptions_repeatSubConfig_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - parseConfigDoubleRecursionCommandLine(); assertThat(eventHandler.getEvents()) .containsExactly( Event.warn( @@ -1197,7 +819,8 @@ public class BlazeOptionHandlerTest { .inOrder(); } - private void parseRepeatConfigs() { + @Test + public void testParseOptions_repeatConfig_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -1212,31 +835,6 @@ public class BlazeOptionHandlerTest { "--config=bar"), eventHandler); assertThat(parser.getResidue()).isEmpty(); - } - - @Test - public void testParseOptions_repeatConfig_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - parseRepeatConfigs(); - assertThat(eventHandler.getEvents()).isEmpty(); - assertThat(optionHandler.getRcfileNotes()) - .containsExactly( - "Found applicable config definition c0:foo in file /somewhere/.blazerc: " - + "--test_multiple_string=foo --config=bar", - "Found applicable config definition c0:baz in file /somewhere/.blazerc: " - + "--test_multiple_string=baz", - "Found applicable config definition c0:bar in file /somewhere/.blazerc: " - + "--test_multiple_string=bar"); - TestOptions options = parser.getOptions(TestOptions.class); - assertThat(options).isNotNull(); - // Foo and bar are not repeated, despite repeat mentions. - assertThat(options.testMultipleString).containsExactly("foo", "baz", "bar").inOrder(); - } - - @Test - public void testParseOptions_repeatConfig_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - parseRepeatConfigs(); assertThat(eventHandler.getEvents()) .containsExactly( Event.warn( @@ -1264,7 +862,8 @@ public class BlazeOptionHandlerTest { .inOrder(); } - private void parseConfigCycleLength1CommandLine() { + @Test + public void testParseOptions_configCycleLength1_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -1275,31 +874,6 @@ public class BlazeOptionHandlerTest { "--rc_source=/somewhere/.blazerc", "--test_multiple_string=explicit"), eventHandler); - } - - @Test - public void testParseOptions_configCycleLength1_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - parseConfigCycleLength1CommandLine(); - assertThat(eventHandler.getEvents()).isEmpty(); - assertThat(parser.getResidue()).isEmpty(); - assertThat(optionHandler.getRcfileNotes()) - .containsExactly( - "Reading rc options for 'c0' from /somewhere/.blazerc:\n" - + " 'c0' options: --config=foo --test_multiple_string=rc", - "Found applicable config definition c0:foo in file /somewhere/.blazerc: " - + "--test_multiple_string=foo --config=foo"); - TestOptions options = parser.getOptions(TestOptions.class); - assertThat(options).isNotNull(); - // The cycle is not expanded, since foo was already expanded once and the fixed point expansion - // does not attempt to expand configs a second time. - assertThat(options.testMultipleString).containsExactly("rc", "foo", "explicit").inOrder(); - } - - @Test - public void testParseOptions_configCycleLength1_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - parseConfigCycleLength1CommandLine(); assertThat(eventHandler.getEvents()) .contains( Event.error( @@ -1307,7 +881,8 @@ public class BlazeOptionHandlerTest { + "inheritance chain [foo]")); } - private void parseConfigCycleLength2CommandLine() { + @Test + public void testParseOptions_configCycleLength2_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -1320,35 +895,6 @@ public class BlazeOptionHandlerTest { "--rc_source=/somewhere/.blazerc", "--test_multiple_string=explicit"), eventHandler); - } - - @Test - public void testParseOptions_configCycleLength2_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - parseConfigCycleLength2CommandLine(); - assertThat(eventHandler.getEvents()).isEmpty(); - assertThat(parser.getResidue()).isEmpty(); - assertThat(optionHandler.getRcfileNotes()) - .containsExactly( - "Reading rc options for 'c0' from /somewhere/.blazerc:\n" - + " 'c0' options: --config=foo --test_multiple_string=rc", - "Found applicable config definition c0:foo in file /somewhere/.blazerc: " - + "--test_multiple_string=foo --config=bar", - "Found applicable config definition c0:bar in file /somewhere/.blazerc: " - + "--test_multiple_string=bar --config=foo"); - TestOptions options = parser.getOptions(TestOptions.class); - assertThat(options).isNotNull(); - // The cycle is not expanded, since foo was already expanded once and the fixed point expansion - // does not attempt to expand configs a second time. - assertThat(options.testMultipleString) - .containsExactly("rc", "foo", "bar", "explicit") - .inOrder(); - } - - @Test - public void testParseOptions_configCycleLength2_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - parseConfigCycleLength2CommandLine(); assertThat(eventHandler.getEvents()) .contains( Event.error( @@ -1356,7 +902,8 @@ public class BlazeOptionHandlerTest { + "inheritance chain [foo, bar]")); } - private void recursivelyIncludedRepeatConfigCommandLine() { + @Test + public void testParseOptions_recursiveConfigWasAlreadyPresent_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -1371,38 +918,6 @@ public class BlazeOptionHandlerTest { "--test_multiple_string=explicit"), eventHandler); assertThat(parser.getResidue()).isEmpty(); - } - - @Test - public void testParseOptions_recursiveConfigWasAlreadyPresent_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - recursivelyIncludedRepeatConfigCommandLine(); - assertThat(eventHandler.getEvents()).isEmpty(); - - // The 2nd config, --config=other, is expanded at the same time as --config=conf, since they are - // both initially present. The "common" definition is therefore first. other is not reexpanded - // when it is added by --config=conf, since it was already included. - assertThat(optionHandler.getRcfileNotes()) - .containsExactly( - "Reading rc options for 'c0' from /somewhere/.blazerc:\n" - + " 'c0' options: --config=other --config=conf --test_multiple_string=rc", - "Found applicable config definition common:other in file /somewhere/.blazerc: " - + "--test_multiple_string=othercommon", - "Found applicable config definition c0:conf in file /somewhere/.blazerc: " - + "--test_multiple_string=config1 --config=other", - "Found applicable config definition c0:other in file /somewhere/.blazerc: " - + "--test_multiple_string=other"); - TestOptions options = parser.getOptions(TestOptions.class); - assertThat(options).isNotNull(); - assertThat(options.testMultipleString) - .containsExactly("rc", "othercommon", "other", "config1", "explicit") - .inOrder(); - } - - @Test - public void testParseOptions_recursiveConfigWasAlreadyPresent_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - recursivelyIncludedRepeatConfigCommandLine(); assertThat(eventHandler.getEvents()) .containsExactly( Event.warn( @@ -1459,7 +974,8 @@ public class BlazeOptionHandlerTest { "--default_override=0:c0:lambda=--config=mu", "--default_override=0:c0:mu=--test_multiple_string=mu"); - private void testParseOptions_longChainOfConfigs_12long() { + @Test + public void testParseOptions_longChain_inPlace() { ImmutableList args = ImmutableList.builder() .add("c0") @@ -1503,19 +1019,6 @@ public class BlazeOptionHandlerTest { "alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", "theta", "iota", "kappa", "lambda", "mu") .inOrder(); - } - - @Test - public void testParseOptions_longChain_FixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testParseOptions_longChainOfConfigs_12long(); - assertThat(eventHandler.getEvents()).isEmpty(); - } - - @Test - public void testParseOptions_longChain_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - testParseOptions_longChainOfConfigs_12long(); // Expect only one warning, we don't want multiple warnings for the same chain. assertThat(eventHandler.getEvents()) .containsExactly( @@ -1539,25 +1042,9 @@ public class BlazeOptionHandlerTest { assertThat(parser.getResidue()).isEmpty(); } - @Test - public void testParseOptions_2LongChains_FixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testParseOptions_twoLongChains(); - // In fixed point, the repetition --config=gamma does not led to a new expansion, but it does - // mean that gamma gets expanded in the first round, so the ordering is weird. - TestOptions options = parser.getOptions(TestOptions.class); - assertThat(options).isNotNull(); - assertThat(options.testMultipleString) - .containsExactly( - "alpha", "gamma", "beta", "delta", "epsilon", "zeta", "eta", "theta", "iota", "kappa", - "lambda", "mu") - .inOrder(); - assertThat(eventHandler.getEvents()).isEmpty(); - } - @Test public void testParseOptions_2LongChains_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); + testParseOptions_twoLongChains(); // Expect the second --config=gamma to have started a second chain, and get warnings about both. TestOptions options = parser.getOptions(TestOptions.class); @@ -1584,7 +1071,8 @@ public class BlazeOptionHandlerTest { + "counted twice and may lead to unexpected behavior.")); } - private void testWarningFlag() { + @Test + public void testWarningFlag_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -1599,18 +1087,7 @@ public class BlazeOptionHandlerTest { } @Test - public void testWarningFlag_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testWarningFlag(); - } - - @Test - public void testWarningFlag_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - testWarningFlag(); - } - - private void testWarningFlag_byConfig_notTriggered() { + public void testWarningFlag_byConfig_notTriggered_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -1624,18 +1101,7 @@ public class BlazeOptionHandlerTest { } @Test - public void testWarningFlag_byConfig_notTriggered_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testWarningFlag_byConfig_notTriggered(); - } - - @Test - public void testWarningFlag_byConfig_notTriggered_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - testWarningFlag_byConfig_notTriggered(); - } - - private void testWarningFlag_byConfig_triggered() { + public void testWarningFlag_byConfig_triggered_inPlace() { optionHandler.parseOptions( ImmutableList.of( "c0", @@ -1653,42 +1119,8 @@ public class BlazeOptionHandlerTest { + "--unconditional_warning=config \"conf\" is deprecated, please stop using!"); } - @Test - public void testWarningFlag_byConfig_triggered_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - testWarningFlag_byConfig_triggered(); - } - - @Test - public void testWarningFlag_byConfig_triggered_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); - testWarningFlag_byConfig_triggered(); - } - - @Test - public void testConfigAfterExplicit_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - optionHandler.parseOptions( - ImmutableList.of( - "c0", - "--test_string=explicitValue", - "--config=conf", - "--default_override=0:c0:conf=--test_string=fromConf", - "--rc_source=/somewhere/.blazerc"), - eventHandler); - TestOptions parseResult = parser.getOptions(TestOptions.class); - assertThat(eventHandler.getEvents()).isEmpty(); - // The fact that --config=conf comes after the explicit value does not matter - assertThat(parseResult.testString).isEqualTo("explicitValue"); - assertThat(optionHandler.getRcfileNotes()) - .containsExactly( - "Found applicable config definition c0:conf in file /somewhere/.blazerc: " - + "--test_string=fromConf"); - } - @Test public void testConfigAfterExplicit_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); optionHandler.parseOptions( ImmutableList.of( "c0", @@ -1713,29 +1145,8 @@ public class BlazeOptionHandlerTest { + "--test_string=fromConf"); } - @Test - public void testExplicitOverridesConfig_fixedPoint() { - makeFixedPointExpandingConfigOptionHandler(); - optionHandler.parseOptions( - ImmutableList.of( - "c0", - "--config=conf", - "--test_string=explicitValue", - "--default_override=0:c0:conf=--test_string=fromConf", - "--rc_source=/somewhere/.blazerc"), - eventHandler); - TestOptions parseResult = parser.getOptions(TestOptions.class); - assertThat(eventHandler.getEvents()).isEmpty(); - assertThat(parseResult.testString).isEqualTo("explicitValue"); - assertThat(optionHandler.getRcfileNotes()) - .containsExactly( - "Found applicable config definition c0:conf in file /somewhere/.blazerc: " - + "--test_string=fromConf"); - } - @Test public void testExplicitOverridesConfig_inPlace() { - makeInPlaceExpandingConfigOptionHandler(); optionHandler.parseOptions( ImmutableList.of( "c0", -- cgit v1.2.3