Use aspect to avoid validation actions blocking test executions

PiperOrigin-RevId: 369890289
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/OutputGroupProviderTest.java b/src/test/java/com/google/devtools/build/lib/analysis/OutputGroupProviderTest.java
index b6a084f..58588b5 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/OutputGroupProviderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/OutputGroupProviderTest.java
@@ -19,6 +19,7 @@
 import static java.util.Arrays.asList;
 
 import com.google.common.collect.ImmutableSet;
+import com.google.devtools.build.lib.analysis.OutputGroupInfo.ValidationMode;
 import java.util.Set;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -33,28 +34,30 @@
   @Test
   public void testDetermineOutputGroupsOverridesDefaults() throws Exception {
     Set<String> outputGroups =
-        determineOutputGroups(ImmutableSet.of("x", "y", "z"), asList("a", "b", "c"), false);
+        determineOutputGroups(
+            ImmutableSet.of("x", "y", "z"), asList("a", "b", "c"), ValidationMode.OFF);
     assertThat(outputGroups).containsExactly("a", "b", "c");
   }
 
   @Test
   public void testDetermineOutputGroupsAddsToDefaults() throws Exception {
     Set<String> outputGroups =
-        determineOutputGroups(ImmutableSet.of("x", "y", "z"), asList("+a"), false);
+        determineOutputGroups(ImmutableSet.of("x", "y", "z"), asList("+a"), ValidationMode.OFF);
     assertThat(outputGroups).containsExactly("x", "y", "z", "a");
   }
 
   @Test
   public void testDetermineOutputGroupsRemovesFromDefaults() throws Exception {
     Set<String> outputGroups =
-        determineOutputGroups(ImmutableSet.of("x", "y", "z"), asList("-y"), false);
+        determineOutputGroups(ImmutableSet.of("x", "y", "z"), asList("-y"), ValidationMode.OFF);
     assertThat(outputGroups).containsExactly("x", "z");
   }
 
   @Test
   public void testDetermineOutputGroupsMixedOverrideAdditionOverrides() throws Exception {
     Set<String> outputGroups =
-        determineOutputGroups(ImmutableSet.of("x", "y", "z"), asList("a", "+b"), false);
+        determineOutputGroups(
+            ImmutableSet.of("x", "y", "z"), asList("a", "+b"), ValidationMode.OFF);
     // The plain "a" causes the default output groups to be overridden.
     assertThat(outputGroups).containsExactly("a", "b");
   }
@@ -62,7 +65,7 @@
   @Test
   public void testDetermineOutputGroupsIgnoresUnknownGroup() throws Exception {
     Set<String> outputGroups =
-        determineOutputGroups(ImmutableSet.of("x", "y", "z"), asList("-foo"), false);
+        determineOutputGroups(ImmutableSet.of("x", "y", "z"), asList("-foo"), ValidationMode.OFF);
     // "foo" doesn't exist, but that shouldn't be a problem.
     assertThat(outputGroups).containsExactly("x", "y", "z");
   }
@@ -70,39 +73,67 @@
   @Test
   public void testDetermineOutputGroupsRemovesPreviouslyAddedGroup() throws Exception {
     Set<String> outputGroups;
-    outputGroups = determineOutputGroups(ImmutableSet.of("x", "y", "z"), asList("+a", "-a"), false);
+    outputGroups =
+        determineOutputGroups(
+            ImmutableSet.of("x", "y", "z"), asList("+a", "-a"), ValidationMode.OFF);
     assertThat(outputGroups).containsExactly("x", "y", "z");
 
     // Order matters here.
-    outputGroups = determineOutputGroups(ImmutableSet.of("x", "y", "z"), asList("-a", "+a"), false);
+    outputGroups =
+        determineOutputGroups(
+            ImmutableSet.of("x", "y", "z"), asList("-a", "+a"), ValidationMode.OFF);
     assertThat(outputGroups).containsExactly("x", "y", "z", "a");
   }
 
   @Test
   public void testDetermineOutputGroupsContainsValidationGroup() throws Exception {
     Set<String> outputGroups =
-        determineOutputGroups(ImmutableSet.of("x", "y", "z"), asList(), true);
+        determineOutputGroups(
+            ImmutableSet.of("x", "y", "z"), asList(), ValidationMode.OUTPUT_GROUP);
     assertThat(outputGroups).containsExactly("x", "y", "z", OutputGroupInfo.VALIDATION);
   }
 
   @Test
   public void testDetermineOutputGroupsContainsValidationGroupAfterOverride() throws Exception {
     Set<String> outputGroups =
-        determineOutputGroups(ImmutableSet.of("x", "y", "z"), asList("foo"), true);
+        determineOutputGroups(
+            ImmutableSet.of("x", "y", "z"), asList("foo"), ValidationMode.OUTPUT_GROUP);
     assertThat(outputGroups).containsExactly("foo", OutputGroupInfo.VALIDATION);
   }
 
   @Test
   public void testDetermineOutputGroupsContainsValidationGroupAfterAdd() throws Exception {
     Set<String> outputGroups =
-        determineOutputGroups(ImmutableSet.of("x", "y", "z"), asList("+a"), true);
+        determineOutputGroups(
+            ImmutableSet.of("x", "y", "z"), asList("+a"), ValidationMode.OUTPUT_GROUP);
     assertThat(outputGroups).containsExactly("x", "y", "z", "a", OutputGroupInfo.VALIDATION);
   }
 
   @Test
   public void testDetermineOutputGroupsContainsValidationGroupAfterRemove() throws Exception {
     Set<String> outputGroups =
-        determineOutputGroups(ImmutableSet.of("x", "y", "z"), asList("-x"), true);
+        determineOutputGroups(
+            ImmutableSet.of("x", "y", "z"), asList("-x"), ValidationMode.OUTPUT_GROUP);
     assertThat(outputGroups).containsExactly("y", "z", OutputGroupInfo.VALIDATION);
   }
+
+  @Test
+  public void testDetermineOutputGroupsContainsValidationGroupDespiteRemove() throws Exception {
+    Set<String> outputGroups =
+        determineOutputGroups(
+            ImmutableSet.of("x", "y", "z"),
+            asList("-" + OutputGroupInfo.VALIDATION),
+            ValidationMode.OUTPUT_GROUP);
+    assertThat(outputGroups).containsExactly("x", "y", "z", OutputGroupInfo.VALIDATION);
+  }
+
+  @Test
+  public void testDetermineOutputGroupsContainsTopLevelValidationGroup() throws Exception {
+    Set<String> outputGroups =
+        determineOutputGroups(
+            ImmutableSet.of("x", "y", "z"),
+            asList("-" + OutputGroupInfo.VALIDATION_TOP_LEVEL),
+            ValidationMode.ASPECT);
+    assertThat(outputGroups).containsExactly("x", "y", "z", OutputGroupInfo.VALIDATION_TOP_LEVEL);
+  }
 }