Add an enum representing the specific build file name (WORKSPACE, BUILD) to the PackageLookupValue to reduce the number of references to the filename "BUILD".
--
MOS_MIGRATED_REVID=129203257
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java
index be33464..0269305 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java
@@ -65,12 +65,6 @@
import com.google.devtools.build.skyframe.SkyFunctionName;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -85,8 +79,11 @@
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
-
import javax.annotation.Nullable;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
/** Tests for {@link FileFunction}. */
@RunWith(JUnit4.class)
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java
index 119205a..e243a82 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java
@@ -51,18 +51,15 @@
import com.google.devtools.build.skyframe.RecordingDifferencer;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
-
import javax.annotation.Nullable;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
/**
* Unit tests of specific functionality of PackageFunction. Note that it's already tested
@@ -102,6 +99,12 @@
}
@Test
+ public void testValidPackage() throws Exception {
+ scratch.file("pkg/BUILD");
+ validPackage(PackageValue.key(PackageIdentifier.parse("@//pkg")));
+ }
+
+ @Test
public void testInconsistentNewPackage() throws Exception {
scratch.file("pkg/BUILD", "subinclude('//foo:sub')");
scratch.file("foo/sub");
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 2b35fa1..b04b798 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.PackageLookupValue.BuildFileName;
import com.google.devtools.build.lib.skyframe.PackageLookupValue.ErrorReason;
import com.google.devtools.build.lib.testutil.FoundationTestCase;
import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
@@ -42,16 +43,14 @@
import com.google.devtools.build.skyframe.SkyFunction;
import com.google.devtools.build.skyframe.SkyFunctionName;
import com.google.devtools.build.skyframe.SkyKey;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
/**
* Tests for {@link PackageLookupFunction}.
@@ -207,6 +206,7 @@
PackageLookupValue packageLookupValue = lookupPackage("parentpackage/everythinggood");
assertTrue(packageLookupValue.packageExists());
assertEquals(rootDirectory, packageLookupValue.getRoot());
+ assertEquals(BuildFileName.BUILD, packageLookupValue.getBuildFileName());
}
@Test
@@ -215,6 +215,7 @@
PackageLookupValue packageLookupValue = lookupPackage("");
assertTrue(packageLookupValue.packageExists());
assertEquals(rootDirectory, packageLookupValue.getRoot());
+ assertEquals(BuildFileName.BUILD, packageLookupValue.getBuildFileName());
}
@Test
@@ -225,7 +226,7 @@
assertTrue(packageLookupValue.packageExists());
assertEquals(rootDirectory, packageLookupValue.getRoot());
}
-
+
@Test
public void testPackageLookupValueHashCodeAndEqualsContract() throws Exception {
Path root1 = rootDirectory.getRelative("root1");
@@ -234,16 +235,22 @@
// PackageLookupValue are supposed to have reference equality semantics, and some are supposed
// to have logical equality semantics.
new EqualsTester()
- .addEqualityGroup(PackageLookupValue.success(root1), PackageLookupValue.success(root1))
- .addEqualityGroup(PackageLookupValue.success(root2), PackageLookupValue.success(root2))
+ .addEqualityGroup(
+ PackageLookupValue.success(root1, BuildFileName.BUILD),
+ PackageLookupValue.success(root1, BuildFileName.BUILD))
+ .addEqualityGroup(
+ PackageLookupValue.success(root2, BuildFileName.BUILD),
+ PackageLookupValue.success(root2, BuildFileName.BUILD))
.addEqualityGroup(
PackageLookupValue.NO_BUILD_FILE_VALUE, PackageLookupValue.NO_BUILD_FILE_VALUE)
.addEqualityGroup(
PackageLookupValue.DELETED_PACKAGE_VALUE, PackageLookupValue.DELETED_PACKAGE_VALUE)
- .addEqualityGroup(PackageLookupValue.invalidPackageName("nope1"),
+ .addEqualityGroup(
+ PackageLookupValue.invalidPackageName("nope1"),
PackageLookupValue.invalidPackageName("nope1"))
- .addEqualityGroup(PackageLookupValue.invalidPackageName("nope2"),
- PackageLookupValue.invalidPackageName("nope2"))
+ .addEqualityGroup(
+ PackageLookupValue.invalidPackageName("nope2"),
+ PackageLookupValue.invalidPackageName("nope2"))
.testEquals();
}
}