Search in sources :

Example 36 with Package

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

the class WorkspaceFileFunctionTest method testListBindFunction.

@Test
public void testListBindFunction() throws Exception {
    String[] lines = { "L = ['foo', 'bar']", "bind(name = '%s/%s' % (L[0], L[1]),", "actual = '//foo:bar')" };
    RootedPath workspacePath = createWorkspaceFile(lines);
    SkyKey key = ExternalPackageFunction.key(workspacePath);
    PackageValue value = (PackageValue) externalSkyFunc.compute(key, getEnv());
    Package pkg = value.getPackage();
    assertEquals(Label.parseAbsolute("//foo:bar"), getLabelMapping(pkg, "foo/bar"));
    MoreAsserts.assertNoEvents(pkg.getEvents());
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) Package(com.google.devtools.build.lib.packages.Package) RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Test(org.junit.Test)

Example 37 with Package

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

the class WorkspaceFileFunctionTest method testInvalidRepo.

@Test
public void testInvalidRepo() throws Exception {
    RootedPath workspacePath = createWorkspaceFile("workspace(name = 'foo$')");
    PackageValue value = (PackageValue) externalSkyFunc.compute(ExternalPackageFunction.key(workspacePath), getEnv());
    Package pkg = value.getPackage();
    assertTrue(pkg.containsErrors());
    MoreAsserts.assertContainsEvent(pkg.getEvents(), "foo$ is not a legal workspace name");
}
Also used : Package(com.google.devtools.build.lib.packages.Package) RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Test(org.junit.Test)

Example 38 with Package

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

the class WorkspaceFileFunctionTest method testBindFunction.

@Test
public void testBindFunction() throws Exception {
    String[] lines = { "bind(name = 'foo/bar',", "actual = '//foo:bar')" };
    RootedPath workspacePath = createWorkspaceFile(lines);
    SkyKey key = ExternalPackageFunction.key(workspacePath);
    PackageValue value = (PackageValue) externalSkyFunc.compute(key, getEnv());
    Package pkg = value.getPackage();
    assertEquals(Label.parseAbsolute("//foo:bar"), getLabelMapping(pkg, "foo/bar"));
    MoreAsserts.assertNoEvents(pkg.getEvents());
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) Package(com.google.devtools.build.lib.packages.Package) RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Test(org.junit.Test)

Example 39 with Package

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

the class WorkspaceFileFunctionTest method testNoWorkspaceFile.

@Test
public void testNoWorkspaceFile() throws Exception {
    // Even though the WORKSPACE exists, Skyframe thinks it doesn't, so it doesn't.
    String[] lines = { "bind(name = 'foo/bar', actual = '//foo:bar')" };
    RootedPath workspacePath = createWorkspaceFile(lines);
    fakeWorkspaceFileValue.setExists(false);
    PackageValue value = (PackageValue) externalSkyFunc.compute(ExternalPackageFunction.key(workspacePath), getEnv());
    Package pkg = value.getPackage();
    assertFalse(pkg.containsErrors());
    MoreAsserts.assertNoEvents(pkg.getEvents());
}
Also used : Package(com.google.devtools.build.lib.packages.Package) RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Test(org.junit.Test)

Example 40 with Package

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

the class GenerateWorkspace method generateFromWorkspace.

private void generateFromWorkspace(List<String> projects) throws InterruptedException {
    for (String project : projects) {
        WorkspaceResolver workspaceResolver = new WorkspaceResolver(resolver, handler);
        Path projectPath = fileSystem.getPath(getAbsolute(project)).getRelative("WORKSPACE");
        Package externalPackage = workspaceResolver.parse(projectPath);
        inputs.add(projectPath.getPathString());
        workspaceResolver.resolveTransitiveDependencies(externalPackage);
    }
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) Package(com.google.devtools.build.lib.packages.Package)

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