diff options
author | ccalvarin <ccalvarin@google.com> | 2018-04-06 10:59:56 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-04-06 11:01:12 -0700 |
commit | c1125de0f9030d90d6c4fcaa0c1f2f1a61018416 (patch) | |
tree | 1a41171781c521062d7aebe351017b91345f86b4 /src/test/java/com/google/devtools/build/lib/runtime | |
parent | 4171fc6b8f1710ce2e3c6e4d233f5004c520b06e (diff) |
Disallow undefined configs by default.
This brings it in line with other flags, where a malformed value is an error.
RELNOTES(INC): --config=foo will error if no 'foo' config exists.
PiperOrigin-RevId: 191910781
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/runtime')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/runtime/BlazeOptionHandlerTest.java | 44 |
1 files changed, 38 insertions, 6 deletions
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 567499ca7d..d9454bcbbd 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 @@ -450,15 +450,47 @@ public class BlazeOptionHandlerTest { 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(); + } catch (OptionsParsingException e) { + assertThat(e).hasMessageThat().contains("Config value other is not defined in any .rc file"); + } + } + + private void testExpandConfigOptions_withConfigForUnapplicableCommand_allowUndefined() + throws Exception { + parser.parse("--config=other", "--allow_undefined_configs"); + 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_inPlace() throws Exception { + public void testExpandConfigOptions_withConfigForUnapplicableCommand_allowUndefined_inPlace() + throws Exception { makeInPlaceExpandingConfigOptionHandler(); - testExpandConfigOptions_withConfigForUnapplicableCommand(); + testExpandConfigOptions_withConfigForUnapplicableCommand_allowUndefined(); assertThat(eventHandler.getEvents()) .contains(Event.warn("Config value other is not defined in any .rc file")); } @@ -486,8 +518,8 @@ public class BlazeOptionHandlerTest { .contains(Event.warn("Config value invalid is not defined in any .rc file")); } - private void testNoAllowUndefinedConfig() throws OptionsParsingException { - parser.parse("--config=invalid", "--noallow_undefined_configs"); + private void testUndefinedConfig() throws OptionsParsingException { + parser.parse("--config=invalid"); optionHandler.expandConfigOptions(eventHandler, ArrayListMultimap.create()); } @@ -495,7 +527,7 @@ public class BlazeOptionHandlerTest { public void testNoAllowUndefinedConfig_fixedPoint() { makeFixedPointExpandingConfigOptionHandler(); try { - testNoAllowUndefinedConfig(); + testUndefinedConfig(); fail(); } catch (OptionsParsingException e) { assertThat(e) @@ -508,7 +540,7 @@ public class BlazeOptionHandlerTest { public void testNoAllowUndefinedConfig_inPlace() { makeInPlaceExpandingConfigOptionHandler(); try { - testNoAllowUndefinedConfig(); + testUndefinedConfig(); fail(); } catch (OptionsParsingException e) { assertThat(e) |