aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/common/options/InvocationPolicySetValueTest.java
diff options
context:
space:
mode:
authorGravatar ccalvarin <ccalvarin@google.com>2017-10-17 23:27:19 +0200
committerGravatar Jakob Buchgraber <buchgr@google.com>2017-10-18 10:28:26 +0200
commit34a9fea78f201caed8ace5c714a0cf288cb97c65 (patch)
treec3bf1099536ea9b4160c346822833ac47dd56554 /src/test/java/com/google/devtools/common/options/InvocationPolicySetValueTest.java
parent1606cf208cc5194b13ca212819371f7e4ba43a6b (diff)
Remove feature to allow expansion flags to have values.
It was added as a potential fix for --config (an expansion flag with values), but this would have required forcing the parser to know the config's expansions at parsing time, which is not currently possible. Instead, we will use the new addition of option-location tracking to make sure we expand options at a the correct place, even if the expansion is triggered after the fact. This is mostly a straight forward undoing of https://github.com/bazelbuild/bazel/commit/7c7255ec8d6da20526c2c4078c57aadaf3dd3612, except where the context has changed. Notably, implicit requirements are effectively treated like expansion flags, so special casing in OptionDescription could be removed. RELNOTES: None. PiperOrigin-RevId: 172514997
Diffstat (limited to 'src/test/java/com/google/devtools/common/options/InvocationPolicySetValueTest.java')
-rw-r--r--src/test/java/com/google/devtools/common/options/InvocationPolicySetValueTest.java129
1 files changed, 0 insertions, 129 deletions
diff --git a/src/test/java/com/google/devtools/common/options/InvocationPolicySetValueTest.java b/src/test/java/com/google/devtools/common/options/InvocationPolicySetValueTest.java
index 1bb13cfea4..c8d08cc110 100644
--- a/src/test/java/com/google/devtools/common/options/InvocationPolicySetValueTest.java
+++ b/src/test/java/com/google/devtools/common/options/InvocationPolicySetValueTest.java
@@ -262,80 +262,6 @@ public class InvocationPolicySetValueTest extends InvocationPolicyEnforcerTestBa
}
@Test
- public void testSetValueWithExpansionFunctionFlags() throws Exception {
- InvocationPolicy.Builder invocationPolicyBuilder = InvocationPolicy.newBuilder();
- invocationPolicyBuilder
- .addFlagPoliciesBuilder()
- .setFlagName("test_expansion_function")
- .getSetValueBuilder()
- .addFlagValue(TestOptions.TEST_EXPANSION_FUNCTION_ACCEPTED_VALUE);
-
- InvocationPolicyEnforcer enforcer = createOptionsPolicyEnforcer(invocationPolicyBuilder);
- // Unrelated flag, but --test_expansion_function is not set
- parser.parse("--test_string=throwaway value");
-
- // The flags that --test_expansion_function expands into should still be their default values
- TestOptions testOptions = getTestOptions();
- assertThat(testOptions.expandedD).isEqualTo(TestOptions.EXPANDED_D_DEFAULT);
-
- enforcer.enforce(parser, BUILD_COMMAND);
-
- // After policy enforcement, the flags should be the values from
- // --test_expansion_function=valueA
- testOptions = getTestOptions();
- assertThat(testOptions.expandedD).isEqualTo(TestOptions.EXPANDED_D_EXPANSION_FUNCTION_VALUE);
- }
-
- @Test
- public void testSetValueWithExpansionFunctionFlagsDefault() throws Exception {
- InvocationPolicy.Builder invocationPolicyBuilder = InvocationPolicy.newBuilder();
- invocationPolicyBuilder
- .addFlagPoliciesBuilder()
- .setFlagName("test_expansion_function")
- .getSetValueBuilder();
-
- InvocationPolicyEnforcer enforcer = createOptionsPolicyEnforcer(invocationPolicyBuilder);
- // Unrelated flag, but --test_expansion_function is not set
- parser.parse("--test_string=throwaway value");
-
- // The flags that --test_expansion_function expands into should still be their default values
- TestOptions testOptions = getTestOptions();
- assertThat(testOptions.expandedD).isEqualTo(TestOptions.EXPANDED_D_DEFAULT);
-
- try {
- enforcer.enforce(parser, BUILD_COMMAND);
- fail();
- } catch (OptionsParsingException e) {
- assertThat(e).hasMessage("Expansion value not set.");
- }
- }
-
- @Test
- public void testSetValueWithExpansionFunctionFlagsWrongValue() throws Exception {
- InvocationPolicy.Builder invocationPolicyBuilder = InvocationPolicy.newBuilder();
- invocationPolicyBuilder
- .addFlagPoliciesBuilder()
- .setFlagName("test_expansion_function")
- .getSetValueBuilder()
- .addFlagValue("unknown_value");
-
- InvocationPolicyEnforcer enforcer = createOptionsPolicyEnforcer(invocationPolicyBuilder);
- // Unrelated flag, but --test_expansion_function is not set
- parser.parse("--test_string=throwaway value");
-
- // The flags that --test_expansion_function expands into should still be their default values
- TestOptions testOptions = getTestOptions();
- assertThat(testOptions.expandedD).isEqualTo(TestOptions.EXPANDED_D_DEFAULT);
-
- try {
- enforcer.enforce(parser, BUILD_COMMAND);
- fail();
- } catch (OptionsParsingException e) {
- assertThat(e).hasMessage("Unrecognized expansion value: unknown_value");
- }
- }
-
- @Test
public void testOverridableSetValueWithExpansionFlags() throws Exception {
InvocationPolicy.Builder invocationPolicyBuilder = InvocationPolicy.newBuilder();
invocationPolicyBuilder
@@ -369,33 +295,6 @@ public class InvocationPolicySetValueTest extends InvocationPolicyEnforcerTestBa
}
@Test
- public void testOverridableSetValueWithExpansionFunction() throws Exception {
- InvocationPolicy.Builder invocationPolicyBuilder = InvocationPolicy.newBuilder();
- invocationPolicyBuilder
- .addFlagPoliciesBuilder()
- .setFlagName("test_expansion_function")
- .getSetValueBuilder()
- .addFlagValue(TestOptions.TEST_EXPANSION_FUNCTION_ACCEPTED_VALUE)
- .setOverridable(true);
-
- InvocationPolicyEnforcer enforcer = createOptionsPolicyEnforcer(invocationPolicyBuilder);
- // Unrelated flag, but --test_expansion_function is not set
- parser.parse("--expanded_d=value that overrides");
-
- // The flags that --test_expansion_function expands into should still be their default values
- // except for the explicitly marked flag.
- TestOptions testOptions = getTestOptions();
- assertThat(testOptions.expandedD).isEqualTo("value that overrides");
-
- enforcer.enforce(parser, "build");
-
- // After policy enforcement, the flags should be the values from --test_expansion_function,
- // except for the user-set value, since the expansion flag was set to overridable.
- testOptions = getTestOptions();
- assertThat(testOptions.expandedD).isEqualTo("value that overrides");
- }
-
- @Test
public void testOverridableSetValueWithExpansionToRepeatingFlag() throws Exception {
InvocationPolicy.Builder invocationPolicyBuilder = InvocationPolicy.newBuilder();
invocationPolicyBuilder
@@ -456,34 +355,6 @@ public class InvocationPolicySetValueTest extends InvocationPolicyEnforcerTestBa
}
@Test
- public void testNonoverridableSetValueWithExpansionFlags() throws Exception {
- InvocationPolicy.Builder invocationPolicyBuilder = InvocationPolicy.newBuilder();
- invocationPolicyBuilder
- .addFlagPoliciesBuilder()
- .setFlagName("test_expansion_function")
- .getSetValueBuilder()
- .addFlagValue(TestOptions.TEST_EXPANSION_FUNCTION_ACCEPTED_VALUE)
- .setOverridable(false);
-
- InvocationPolicyEnforcer enforcer = createOptionsPolicyEnforcer(invocationPolicyBuilder);
- // Unrelated flag, but --test_expansion_function is not set
- parser.parse("--expanded_d=value to override");
-
- // The flags that --test_expansion_function expands into should still be their default values
- // except for the explicitly marked flag.
- TestOptions testOptions = getTestOptions();
- assertThat(testOptions.expandedD).isEqualTo("value to override");
-
- enforcer.enforce(parser, "build");
-
- // After policy enforcement, the flags should be the values from --test_expansion_function,
- // including the value that the user tried to set, since the expansion flag was set
- // non-overridably.
- testOptions = getTestOptions();
- assertThat(testOptions.expandedD).isEqualTo(TestOptions.EXPANDED_D_EXPANSION_FUNCTION_VALUE);
- }
-
- @Test
public void testNonOverridableSetValueWithExpansionToRepeatingFlag() throws Exception {
InvocationPolicy.Builder invocationPolicyBuilder = InvocationPolicy.newBuilder();
invocationPolicyBuilder