Adds an enum to describe how PackageLookupFunction should handle package labels
which cross into a sub-repository. Part of #1592.

--
MOS_MIGRATED_REVID=135931868
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java
index b04b798..c200c41 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java
@@ -29,6 +29,7 @@
 import com.google.devtools.build.lib.events.NullEventHandler;
 import com.google.devtools.build.lib.packages.RuleClassProvider;
 import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
+import com.google.devtools.build.lib.skyframe.PackageLookupFunction.CrossRepositoryLabelViolationStrategy;
 import com.google.devtools.build.lib.skyframe.PackageLookupValue.BuildFileName;
 import com.google.devtools.build.lib.skyframe.PackageLookupValue.ErrorReason;
 import com.google.devtools.build.lib.testutil.FoundationTestCase;
@@ -52,16 +53,15 @@
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
-/**
- * Tests for {@link PackageLookupFunction}.
- */
-@RunWith(JUnit4.class)
-public class PackageLookupFunctionTest extends FoundationTestCase {
+/** Tests for {@link PackageLookupFunction}. */
+public abstract class PackageLookupFunctionTest extends FoundationTestCase {
   private AtomicReference<ImmutableSet<PackageIdentifier>> deletedPackages;
   private MemoizingEvaluator evaluator;
   private SequentialBuildDriver driver;
   private RecordingDifferencer differencer;
 
+  protected abstract CrossRepositoryLabelViolationStrategy crossRepositoryLabelViolationStrategy();
+
   @Before
   public final void setUp() throws Exception {
     Path emptyPackagePath = rootDirectory.getRelative("somewhere/else");
@@ -78,8 +78,9 @@
         pkgLocator, false, directories);
 
     Map<SkyFunctionName, SkyFunction> skyFunctions = new HashMap<>();
-    skyFunctions.put(SkyFunctions.PACKAGE_LOOKUP,
-        new PackageLookupFunction(deletedPackages));
+    skyFunctions.put(
+        SkyFunctions.PACKAGE_LOOKUP,
+        new PackageLookupFunction(deletedPackages, crossRepositoryLabelViolationStrategy()));
     skyFunctions.put(
         SkyFunctions.PACKAGE,
         new PackageFunction(null, null, null, null, null, null, null));
@@ -253,4 +254,36 @@
             PackageLookupValue.invalidPackageName("nope2"))
         .testEquals();
   }
+
+  /**
+   * Runs all tests in the base {@link PackageLookupFunctionTest} class with the
+   * {@link CrossRepositoryLabelViolationStrategy#IGNORE} enum set, and also additional tests
+   * specific to that setting.
+   */
+  @RunWith(JUnit4.class)
+  public static class IgnoreLabelViolationsTest
+      extends PackageLookupFunctionTest {
+    @Override
+    protected CrossRepositoryLabelViolationStrategy crossRepositoryLabelViolationStrategy() {
+      return CrossRepositoryLabelViolationStrategy.IGNORE;
+    }
+
+    // Add any ignore-specific tests here.
+  }
+
+  /**
+   * Runs all tests in the base {@link PackageLookupFunctionTest} class with the
+   * {@link CrossRepositoryLabelViolationStrategy#ERROR} enum set, and also additional tests
+   * specific to that setting.
+   */
+  @RunWith(JUnit4.class)
+  public static class ErrorLabelViolationsTest
+      extends PackageLookupFunctionTest {
+    @Override
+    protected CrossRepositoryLabelViolationStrategy crossRepositoryLabelViolationStrategy() {
+      return CrossRepositoryLabelViolationStrategy.ERROR;
+    }
+
+    // Add any error-specific tests here.
+  }
 }