aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/actions
diff options
context:
space:
mode:
authorGravatar Kristina Chodorow <kchodorow@google.com>2016-06-16 20:30:57 +0000
committerGravatar Yue Gan <yueg@google.com>2016-06-17 09:26:21 +0000
commitbdfd58a8ca2ed5735d6aaa5b238fb0f689515724 (patch)
treefd40061fd63c6d4403d04e94af05d16ded2cab42 /src/test/java/com/google/devtools/build/lib/actions
parent3b62451a3c9e5eba3a892473d406cd02d84db5c3 (diff)
Make the execution root match the runfiles tree structure for external repositories
One interesting side effect of how this is implemented is that for external repositories, bin/ and genfiles/ are combined. External repo output is under bazel-out/local-fastbuild/repo_name for each repo. Fixes #1262. RELNOTES[INC]: Previously, an external repository would be symlinked into the execution root at execroot/local_repo/external/remote_repo. This changes it to be at execroot/remote_repo. This may break genrules/Skylark actions that hardcode execution root paths. If this causes breakages for you, ensure that genrules are using $(location :target) to access files and Skylark rules are using http://bazel.io/docs/skylark/lib/File.html's path, dirname, etc. functions. -- MOS_MIGRATED_REVID=125095799
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/actions')
-rw-r--r--src/test/java/com/google/devtools/build/lib/actions/ArtifactFactoryTest.java23
-rw-r--r--src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java9
2 files changed, 16 insertions, 16 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/actions/ArtifactFactoryTest.java b/src/test/java/com/google/devtools/build/lib/actions/ArtifactFactoryTest.java
index f9c31ca044..317051b9d4 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/ArtifactFactoryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/ArtifactFactoryTest.java
@@ -150,25 +150,26 @@ public class ArtifactFactoryTest {
}
@Test
- public void testResolveArtifactWithUpLevelFailsCleanly() throws Exception {
+ public void testResolveArtifactWithUpLevel() throws Exception {
// We need a package in the root directory to make every exec path (even one with up-level
// references) be in a package.
Map<PackageIdentifier, Root> packageRoots = ImmutableMap.of(
- PackageIdentifier.createInMainRepo(new PathFragment("")), clientRoot);
+ PackageIdentifier.create("@workspace", new PathFragment("")), clientRoot,
+ PackageIdentifier.create("@repo", new PathFragment("dir")), clientRoot);
artifactFactory.setPackageRoots(packageRoots);
- PathFragment outsideWorkspace = new PathFragment("../foo");
- PathFragment insideWorkspace =
- new PathFragment("../" + clientRoot.getPath().getBaseName() + "/foo");
- assertNull(artifactFactory.resolveSourceArtifact(outsideWorkspace));
- assertNull("Up-level-containing paths that descend into the right workspace aren't allowed",
- artifactFactory.resolveSourceArtifact(insideWorkspace));
+ PathFragment topLevel = new PathFragment("../workspace/foo");
+ PathFragment subdir = new PathFragment("../repo/dir/foo");
+ Artifact topLevelArtifact = artifactFactory.resolveSourceArtifact(topLevel);
+ assertThat(topLevelArtifact).isNotNull();
+ Artifact subdirArtifact = artifactFactory.resolveSourceArtifact(subdir);
+ assertThat(subdirArtifact).isNotNull();
MockPackageRootResolver packageRootResolver = new MockPackageRootResolver();
packageRootResolver.setPackageRoots(packageRoots);
Map<PathFragment, Artifact> result = new HashMap<>();
- result.put(insideWorkspace, null);
- result.put(outsideWorkspace, null);
+ result.put(topLevel, topLevelArtifact);
+ result.put(subdir, subdirArtifact);
assertThat(
- artifactFactory.resolveSourceArtifacts(ImmutableList.of(insideWorkspace, outsideWorkspace),
+ artifactFactory.resolveSourceArtifacts(ImmutableList.of(topLevel, subdir),
packageRootResolver).entrySet()).containsExactlyElementsIn(result.entrySet());
}
diff --git a/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java b/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
index e43ddd1b28..676eab402a 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
@@ -57,13 +57,12 @@ public class ArtifactTest {
}
@Test
- public void testConstruction_badRootDir() throws IOException {
+ public void testConstruction_UplevelRootDir() throws IOException {
Path f1 = scratch.file("/exec/dir/file.ext");
Path bogusDir = scratch.file("/exec/dir/bogus");
- try {
- new Artifact(f1, Root.asDerivedRoot(bogusDir), f1.relativeTo(execDir));
- fail("Expected IllegalArgumentException constructing artifact with a bad root dir");
- } catch (IllegalArgumentException expected) {}
+ Artifact artifact = new Artifact(f1, Root.asDerivedRoot(bogusDir), f1.relativeTo(execDir));
+ assertThat(artifact.getExecPath()).isEqualTo(new PathFragment("dir/file.ext"));
+ assertThat(artifact.getRootRelativePath()).isEqualTo(new PathFragment("../file.ext"));
}
@Test