use of com.google.devtools.build.lib.vfs.RootedPath 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());
}
use of com.google.devtools.build.lib.vfs.RootedPath 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");
}
use of com.google.devtools.build.lib.vfs.RootedPath in project bazel by bazelbuild.
the class WorkspaceFileFunctionTest method createWorkspaceFile.
private RootedPath createWorkspaceFile(String... contents) throws IOException {
Path workspacePath = scratch.overwriteFile("WORKSPACE", contents);
fakeWorkspaceFileValue.setSize(workspacePath.getFileSize());
return RootedPath.toRootedPath(workspacePath.getParentDirectory(), new PathFragment(workspacePath.getBaseName()));
}
use of com.google.devtools.build.lib.vfs.RootedPath 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());
}
use of com.google.devtools.build.lib.vfs.RootedPath 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());
}
Aggregations