Rolling forward https://github.com/bazelbuild/bazel/commit/23f171e2208700dc2f2f65f5ccb32bacd7aec87d, but looking for PackageLookupValues, which are guaranteed to be present if a bzl file has been loaded, as opposed to PackageValues, which are not.

*** Original change description (substitute "package lookup" for "package" everywhere to update the description) ***

Avoid touching the filesystem to see what the BUILD file for a Starlark extension was: we already have the package, so we can just read it out.

Genquery remains buggy here.

haxorz@ observed in http://b/123795023#comment6 that we only need to read these paths to determine if the package was defined in a BUILD or BUILD.bazel file. Since the package already knows that, we just ask it.

***

PiperOrigin-RevId: 389960483
diff --git a/src/test/java/com/google/devtools/build/lib/packages/GlobCacheTest.java b/src/test/java/com/google/devtools/build/lib/packages/GlobCacheTest.java
index d90c55c..f1b693f 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/GlobCacheTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/GlobCacheTest.java
@@ -110,6 +110,12 @@
                   return null;
                 }
               }
+
+              @Override
+              public String getBaseNameForLoadedPackage(PackageIdentifier packageName) {
+                Path buildFileForPackage = getBuildFileForPackage(packageName);
+                return buildFileForPackage == null ? null : buildFileForPackage.getBaseName();
+              }
             },
             null,
             TestUtils.getPool(),