aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java45
1 files changed, 37 insertions, 8 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java
index 734f7d4f09..f8bacacf9a 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java
@@ -21,12 +21,15 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.Root;
+import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.events.EventKind;
import com.google.devtools.build.lib.testutil.FoundationTestCase;
import com.google.devtools.build.lib.vfs.PathFragment;
+
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -318,36 +321,37 @@ public class RunfilesTest extends FoundationTestCase {
@Test
public void testLegacyRunfilesStructure() {
- Root root = Root.asSourceRoot(scratch.resolve("/workspace/external/repo"));
+ Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
PathFragment workspaceName = new PathFragment("wsname");
- PathFragment pathB = new PathFragment("b");
+ PathFragment pathB = new PathFragment("external/repo/b");
Artifact artifactB = new Artifact(pathB, root);
Runfiles.ManifestBuilder builder = new Runfiles.ManifestBuilder(workspaceName, true);
Map<PathFragment, Artifact> inputManifest = Maps.newHashMap();
- inputManifest.put(new PathFragment("../repo").getRelative(pathB), artifactB);
+ inputManifest.put(pathB, artifactB);
Runfiles.ConflictChecker checker = new Runfiles.ConflictChecker(
Runfiles.ConflictPolicy.WARN, reporter, null);
builder.addUnderWorkspace(inputManifest, checker);
assertThat(builder.build().entrySet()).containsExactly(
- Maps.immutableEntry(workspaceName.getRelative("external/repo/b"), artifactB),
+ Maps.immutableEntry(workspaceName.getRelative(pathB), artifactB),
Maps.immutableEntry(new PathFragment("repo/b"), artifactB));
assertNoEvents();
}
@Test
public void testRunfileAdded() {
- Root root = Root.asSourceRoot(scratch.resolve("/workspace/external/repo"));
+ Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
PathFragment workspaceName = new PathFragment("wsname");
- PathFragment pathB = new PathFragment("b");
+ PathFragment pathB = new PathFragment("external/repo/b");
Artifact artifactB = new Artifact(pathB, root);
Runfiles.ManifestBuilder builder = new Runfiles.ManifestBuilder(workspaceName, false);
- Map<PathFragment, Artifact> inputManifest = ImmutableMap.of(
- new PathFragment("../repo").getRelative(pathB), artifactB);
+ Map<PathFragment, Artifact> inputManifest = ImmutableMap.<PathFragment, Artifact>builder()
+ .put(pathB, artifactB)
+ .build();
Runfiles.ConflictChecker checker = new Runfiles.ConflictChecker(
Runfiles.ConflictPolicy.WARN, reporter, null);
builder.addUnderWorkspace(inputManifest, checker);
@@ -357,4 +361,29 @@ public class RunfilesTest extends FoundationTestCase {
Maps.immutableEntry(new PathFragment("repo/b"), artifactB));
assertNoEvents();
}
+
+ // TODO(kchodorow): remove this once the default workspace name is always set.
+ @Test
+ public void testConflictWithExternal() {
+ Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
+ PathFragment pathB = new PathFragment("repo/b");
+ PathFragment externalPathB = Label.EXTERNAL_PACKAGE_NAME.getRelative(pathB);
+ Artifact artifactB = new Artifact(pathB, root);
+ Artifact artifactExternalB = new Artifact(externalPathB, root);
+
+ Runfiles.ManifestBuilder builder = new Runfiles.ManifestBuilder(
+ PathFragment.EMPTY_FRAGMENT, false);
+
+ Map<PathFragment, Artifact> inputManifest = ImmutableMap.<PathFragment, Artifact>builder()
+ .put(pathB, artifactB)
+ .put(externalPathB, artifactExternalB)
+ .build();
+ Runfiles.ConflictChecker checker = new Runfiles.ConflictChecker(
+ Runfiles.ConflictPolicy.WARN, reporter, null);
+ builder.addUnderWorkspace(inputManifest, checker);
+
+ assertThat(builder.build().entrySet()).containsExactly(
+ Maps.immutableEntry(new PathFragment("repo/b"), artifactExternalB));
+ checkConflictWarning();
+ }
}