aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/runtime
diff options
context:
space:
mode:
authorGravatar ccalvarin <ccalvarin@google.com>2017-04-10 15:58:11 +0000
committerGravatar Jakob Buchgraber <buchgr@google.com>2017-04-11 10:50:06 +0200
commitba511908f6b53248c42bae22c6eeb110ec5940da (patch)
tree930e735c91065ce011e539511ea2fc034615ea3a /src/test/java/com/google/devtools/build/lib/runtime
parentbb5295b2dcae85c5011c912373ec57539070ebc5 (diff)
Add --all_incompatible_changes invocation policy test.
By the time the invocation policy gets enforced, the expansion flag should have been expanded, and policy should act as on any other expansion flag. PiperOrigin-RevId: 152692831
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/runtime')
-rw-r--r--src/test/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansionTest.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansionTest.java b/src/test/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansionTest.java
index c99246bb3a..7f32df9ba1 100644
--- a/src/test/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansionTest.java
@@ -17,6 +17,9 @@ package com.google.devtools.build.lib.runtime;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
+import com.google.devtools.build.lib.flags.InvocationPolicyEnforcer;
+import com.google.devtools.build.lib.runtime.proto.InvocationPolicyOuterClass.InvocationPolicy;
+import com.google.devtools.build.lib.runtime.proto.InvocationPolicyOuterClass.UseDefault;
import com.google.devtools.common.options.Converters;
import com.google.devtools.common.options.ExpansionFunction;
import com.google.devtools.common.options.IsolatedOptionsData;
@@ -144,6 +147,30 @@ public class AllIncompatibleChangesExpansionTest {
assertThat(opts.incompatibleB).isTrue();
}
+ @Test
+ public void invocationPolicy() throws OptionsParsingException {
+ // Check that all-expansion behaves just like any other expansion flag and can be filtered
+ // by invocation policy.
+ InvocationPolicy.Builder invocationPolicyBuilder = InvocationPolicy.newBuilder();
+ invocationPolicyBuilder.addFlagPoliciesBuilder()
+ .setFlagName("incompatible_A")
+ .setUseDefault(UseDefault.getDefaultInstance())
+ .build();
+ InvocationPolicy policy = invocationPolicyBuilder.build();
+ InvocationPolicyEnforcer enforcer = new InvocationPolicyEnforcer(policy);
+
+ OptionsParser parser =
+ OptionsParser.newOptionsParser(ExampleOptions.class);
+ parser.parse("--all");
+ enforcer.enforce(parser);
+
+ ExampleOptions opts = parser.getOptions(ExampleOptions.class);
+ assertThat(opts.x).isFalse();
+ assertThat(opts.y).isTrue();
+ assertThat(opts.incompatibleA).isFalse(); // A should have been removed from the expansion.
+ assertThat(opts.incompatibleB).isTrue(); // B, without a policy, should have been left alone.
+ }
+
// There's no unit test to check that the expansion of --all is sorted. IsolatedOptionsData is not
// exposed from OptionsParser, making it difficult to check, and it's not clear that exposing it
// would be worth it.