Search in sources :

Example 56 with Package

use of com.google.devtools.build.lib.packages.Package in project bazel by bazelbuild.

the class CircularDependencyTest method testInputOutputConflictDifferentPackage.

/**
   * Test not to detect implicit input/output file overlap in rules,
   * when coming from a different package.
   */
@Test
public void testInputOutputConflictDifferentPackage() throws Exception {
    Package pkg = createScratchPackageForImplicitCycle("googledata/xxx", "genrule(name='geo',", "    srcs = ['//googledata/geo:geo_info.txt'],", "    outs = ['geoinfo.txt'],", "    cmd = '$(SRCS) > $@')");
    assertFalse(pkg.containsErrors());
}
Also used : Package(com.google.devtools.build.lib.packages.Package) Test(org.junit.Test)

Example 57 with Package

use of com.google.devtools.build.lib.packages.Package in project bazel by bazelbuild.

the class PackageCacheTest method testASTIsNotRetained.

@Test
public void testASTIsNotRetained() throws Exception {
    createPkg1();
    Package pkg1 = getPackage("pkg1");
    MoreAsserts.assertInstanceOfNotReachable(pkg1, BuildFileAST.class);
}
Also used : Package(com.google.devtools.build.lib.packages.Package) Test(org.junit.Test)

Example 58 with Package

use of com.google.devtools.build.lib.packages.Package in project bazel by bazelbuild.

the class PackageCacheTest method assertPackageLoadingFails.

private void assertPackageLoadingFails(String pkgName, String expectedError) throws Exception {
    Package pkg = getPackage(pkgName);
    assertTrue(pkg.containsErrors());
    assertContainsEvent(expectedError);
}
Also used : Package(com.google.devtools.build.lib.packages.Package)

Example 59 with Package

use of com.google.devtools.build.lib.packages.Package in project bazel by bazelbuild.

the class PackageCacheTest method testRepeatedAttemptsToParseMissingPackage.

/**
   * A missing package is one for which no BUILD file can be found.  The
   * PackageCache caches failures of this kind until the next sync.
   */
@Test
public void testRepeatedAttemptsToParseMissingPackage() throws Exception {
    checkGetPackageFails("missing", "no such package 'missing': " + "BUILD file not found on package path");
    // Still missing:
    checkGetPackageFails("missing", "no such package 'missing': " + "BUILD file not found on package path");
    // Update the BUILD file on disk so "missing" is no longer missing:
    scratch.file("missing/BUILD", "# an ok build file");
    // Still missing:
    checkGetPackageFails("missing", "no such package 'missing': " + "BUILD file not found on package path");
    invalidatePackages();
    // Found:
    Package missing = getPackage("missing");
    assertEquals("missing", missing.getName());
}
Also used : Package(com.google.devtools.build.lib.packages.Package) Test(org.junit.Test)

Example 60 with Package

use of com.google.devtools.build.lib.packages.Package in project bazel by bazelbuild.

the class PackageCacheTest method testPackageInErrorReloadedWhenFixed.

@Test
public void testPackageInErrorReloadedWhenFixed() throws Exception {
    reporter.removeHandler(failFastHandler);
    Path build = scratch.file("a/BUILD", "cc_library(name='a', feet='stinky')");
    build.setLastModifiedTime(1);
    Package a1 = getPackage("a");
    assertTrue(a1.containsErrors());
    assertContainsEvent("//a:a: no such attribute 'feet'");
    eventCollector.clear();
    build.delete();
    build = scratch.file("a/BUILD", "cc_library(name='a', srcs=['a.cc'])");
    build.setLastModifiedTime(2);
    invalidatePackages();
    Package a2 = getPackage("a");
    assertNotSame(a1, a2);
    assertFalse(a2.containsErrors());
    assertNoEvents();
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) Package(com.google.devtools.build.lib.packages.Package) Test(org.junit.Test)

Aggregations

Package (com.google.devtools.build.lib.packages.Package)61 SkyKey (com.google.devtools.build.skyframe.SkyKey)25 Test (org.junit.Test)20 PackageIdentifier (com.google.devtools.build.lib.cmdline.PackageIdentifier)14 NoSuchPackageException (com.google.devtools.build.lib.packages.NoSuchPackageException)14 Label (com.google.devtools.build.lib.cmdline.Label)13 Path (com.google.devtools.build.lib.vfs.Path)13 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)13 Target (com.google.devtools.build.lib.packages.Target)12 NoSuchTargetException (com.google.devtools.build.lib.packages.NoSuchTargetException)11 Nullable (javax.annotation.Nullable)10 BuildFileContainsErrorsException (com.google.devtools.build.lib.packages.BuildFileContainsErrorsException)8 ImmutableMap (com.google.common.collect.ImmutableMap)7 ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)5 BuildFileNotFoundException (com.google.devtools.build.lib.packages.BuildFileNotFoundException)5 LinkedHashSet (java.util.LinkedHashSet)5 LabelSyntaxException (com.google.devtools.build.lib.cmdline.LabelSyntaxException)4 SkyValue (com.google.devtools.build.skyframe.SkyValue)4 InvalidConfigurationException (com.google.devtools.build.lib.analysis.config.InvalidConfigurationException)3 Attribute (com.google.devtools.build.lib.packages.Attribute)3