aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar Kristina Chodorow <kchodorow@google.com>2016-04-19 13:55:24 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-04-20 11:12:35 +0000
commit857cda2c45a5cc68c3fa398311c48c571a64915d (patch)
tree8a2ad9cd0c92752b1b6105c27d9995dcaf3d24a4 /src/test
parent0b26f446f8312d1c43d162fe706467ef458c4db8 (diff)
Move the runfiles for external repositories to under the x.runfiles/ directory
This also sets the Bazel workspace name to io_bazel_source. Fixes #848. Relevant to #1116, #1124, RELNOTES[INC]: All repositories are now directly under the x.runfiles directory in the runfiles tree (previously, external repositories were at x.runfiles/main-repo/external/other-repo. This simplifies handling remote repository runfiles considerably, but will break existing references to external repository runfiles. --- Furthermore, if a Bazel project does not provide a workspace name in the WORKSPACE file, Bazel will now default to using __main__ as the workspace name (instead of "", as previously). The repository's runfiles will appear under x.runfiles/__main__/. -- MOS_MIGRATED_REVID=120224534
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/RunfilesSupplierImplTest.java2
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java224
-rw-r--r--src/test/java/com/google/devtools/build/lib/cmdline/PackageIdentifierTest.java8
-rw-r--r--src/test/java/com/google/devtools/build/lib/cmdline/RepositoryNameTest.java11
-rw-r--r--src/test/java/com/google/devtools/build/lib/packages/util/MockToolsConfig.java4
-rw-r--r--src/test/java/com/google/devtools/build/lib/testutil/TestConstants.java11
-rwxr-xr-xsrc/test/shell/bazel/bazel_example_test.sh17
-rwxr-xr-xsrc/test/shell/bazel/bazel_rules_test.sh6
-rwxr-xr-xsrc/test/shell/bazel/bazel_sandboxing_test.sh2
-rwxr-xr-xsrc/test/shell/bazel/external_integration_test.sh12
-rwxr-xr-xsrc/test/shell/bazel/generate_workspace_test.sh2
-rwxr-xr-xsrc/test/shell/bazel/git_repository_test.sh8
-rwxr-xr-xsrc/test/shell/bazel/local_repository_test.sh2
-rwxr-xr-xsrc/test/shell/bazel/testenv.sh3
-rwxr-xr-xsrc/test/shell/integration/runfiles_test.sh7
15 files changed, 176 insertions, 143 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesSupplierImplTest.java b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesSupplierImplTest.java
index 8626f6913e..70024c460e 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesSupplierImplTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesSupplierImplTest.java
@@ -86,7 +86,7 @@ public class RunfilesSupplierImplTest {
}
private static Runfiles mkRunfiles(Iterable<Artifact> artifacts) {
- return new Runfiles.Builder("TESTING").addArtifacts(artifacts).build();
+ return new Runfiles.Builder("TESTING", false).addArtifacts(artifacts).build();
}
private static List<Artifact> mkArtifacts(Root rootDir, String... paths) {
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 7b806f371d..ef2373f6ae 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
@@ -22,16 +22,13 @@ import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.Root;
import com.google.devtools.build.lib.events.EventKind;
import com.google.devtools.build.lib.testutil.FoundationTestCase;
+import com.google.devtools.build.lib.testutil.TestConstants;
import com.google.devtools.build.lib.vfs.PathFragment;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
/**
* Test for {@link Runfiles}.
*/
@@ -45,79 +42,92 @@ public class RunfilesTest extends FoundationTestCase {
assertEquals(EventKind.WARNING, Iterables.getOnlyElement(eventCollector).getKind());
}
+ private Runfiles.RunfilesPath runfilesPath(String path) {
+ return runfilesPath(new PathFragment(path));
+ }
+
+ private Runfiles.RunfilesPath runfilesPath(PathFragment path) {
+ return Runfiles.RunfilesPath.alreadyResolved(
+ path, new PathFragment(TestConstants.WORKSPACE_NAME));
+ }
+
@Test
public void testFilterListForObscuringSymlinksCatchesBadObscurer() throws Exception {
- Map<PathFragment, Artifact> obscuringMap = new HashMap<>();
PathFragment pathA = new PathFragment("a");
Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
Artifact artifactA = new Artifact(new PathFragment("a"), root);
- obscuringMap.put(pathA, artifactA);
- obscuringMap.put(new PathFragment("a/b"), new Artifact(new PathFragment("c/b"),
- root));
- assertThat(Runfiles.filterListForObscuringSymlinks(reporter, null, obscuringMap).entrySet())
+ Runfiles.ManifestBuilder builder = new Runfiles.ManifestBuilder(
+ null, PathFragment.EMPTY_FRAGMENT, false);
+ builder.put(runfilesPath("a"), artifactA);
+ builder.put(runfilesPath("a/b"), new Artifact(new PathFragment("c/b"), root));
+ assertThat(builder.filterListForObscuringSymlinks(reporter, null).build().entrySet())
.containsExactly(Maps.immutableEntry(pathA, artifactA)).inOrder();
checkWarning();
}
@Test
public void testFilterListForObscuringSymlinksCatchesBadGrandParentObscurer() throws Exception {
- Map<PathFragment, Artifact> obscuringMap = new HashMap<>();
+ Runfiles.ManifestBuilder obscuringMap = new Runfiles.ManifestBuilder(
+ null, PathFragment.EMPTY_FRAGMENT, false);
PathFragment pathA = new PathFragment("a");
Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
- Artifact artifactA = new Artifact(new PathFragment("a"),
- root);
- obscuringMap.put(pathA, artifactA);
- obscuringMap.put(new PathFragment("a/b/c"), new Artifact(new PathFragment("b/c"),
- root));
- assertThat(Runfiles.filterListForObscuringSymlinks(reporter, null, obscuringMap).entrySet())
+ Artifact artifactA = new Artifact(new PathFragment("a"), root);
+
+ obscuringMap.put(runfilesPath("a"), artifactA);
+ obscuringMap.put(runfilesPath("a/b/c"), new Artifact(new PathFragment("b/c"), root));
+ assertThat(obscuringMap.filterListForObscuringSymlinks(reporter, null).build().entrySet())
.containsExactly(Maps.immutableEntry(pathA, artifactA)).inOrder();
checkWarning();
}
@Test
public void testFilterListForObscuringSymlinksCatchesBadObscurerNoListener() throws Exception {
- Map<PathFragment, Artifact> obscuringMap = new HashMap<>();
+ Runfiles.ManifestBuilder obscuringMap = new Runfiles.ManifestBuilder(
+ null, PathFragment.EMPTY_FRAGMENT, false);
PathFragment pathA = new PathFragment("a");
Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
Artifact artifactA = new Artifact(new PathFragment("a"),
root);
- obscuringMap.put(pathA, artifactA);
- obscuringMap.put(new PathFragment("a/b"), new Artifact(new PathFragment("c/b"),
- root));
- assertThat(Runfiles.filterListForObscuringSymlinks(null, null, obscuringMap).entrySet())
+ obscuringMap.put(runfilesPath("a"), artifactA);
+ obscuringMap.put(runfilesPath("a/b"), new Artifact(new PathFragment("c/b"), root));
+ assertThat(obscuringMap.filterListForObscuringSymlinks(null, null).build().entrySet())
.containsExactly(Maps.immutableEntry(pathA, artifactA)).inOrder();
}
@Test
public void testFilterListForObscuringSymlinksIgnoresOkObscurer() throws Exception {
- Map<PathFragment, Artifact> obscuringMap = new HashMap<>();
+ Runfiles.ManifestBuilder obscuringMap = new Runfiles.ManifestBuilder(
+ null, PathFragment.EMPTY_FRAGMENT, false);
PathFragment pathA = new PathFragment("a");
Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
Artifact artifactA = new Artifact(new PathFragment("a"),
root);
- obscuringMap.put(pathA, artifactA);
- obscuringMap.put(new PathFragment("a/b"), new Artifact(new PathFragment("a/b"),
- root));
+ obscuringMap.put(runfilesPath("a"), artifactA);
+ obscuringMap.put(runfilesPath("a/b"), new Artifact(new PathFragment("a/b"), root));
- assertThat(Runfiles.filterListForObscuringSymlinks(reporter, null, obscuringMap).entrySet())
+ assertThat(obscuringMap.filterListForObscuringSymlinks(reporter, null).build().entrySet())
.containsExactly(Maps.immutableEntry(pathA, artifactA)).inOrder();
assertNoEvents();
}
@Test
public void testFilterListForObscuringSymlinksNoObscurers() throws Exception {
- Map<PathFragment, Artifact> obscuringMap = new HashMap<>();
+ Runfiles.ManifestBuilder obscuringMap = new Runfiles.ManifestBuilder(
+ null, PathFragment.EMPTY_FRAGMENT, false);
PathFragment pathA = new PathFragment("a");
Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
Artifact artifactA = new Artifact(new PathFragment("a"),
root);
- obscuringMap.put(pathA, artifactA);
+ obscuringMap.put(
+ Runfiles.RunfilesPath.alreadyResolved(
+ pathA, new PathFragment(TestConstants.WORKSPACE_NAME)),
+ artifactA);
PathFragment pathBC = new PathFragment("b/c");
Artifact artifactBC = new Artifact(new PathFragment("a/b"),
root);
- obscuringMap.put(pathBC, artifactBC);
- assertThat(Runfiles.filterListForObscuringSymlinks(reporter, null, obscuringMap)
- .entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactA),
+ obscuringMap.put(runfilesPath(pathBC), artifactBC);
+ assertThat(obscuringMap.filterListForObscuringSymlinks(reporter, null).build()
+ .entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactA),
Maps.immutableEntry(pathBC, artifactBC));
assertNoEvents();
}
@@ -140,14 +150,15 @@ public class RunfilesTest extends FoundationTestCase {
PathFragment pathA = new PathFragment("a");
Artifact artifactB = new Artifact(new PathFragment("b"), root);
Artifact artifactC = new Artifact(new PathFragment("c"), root);
- Map<PathFragment, Artifact> map = new LinkedHashMap<>();
-
- Runfiles.ConflictChecker checker =
- new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null);
- checker.put(map, pathA, artifactB);
- assertThat(map.entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactB));
- checker.put(map, pathA, artifactC);
- assertThat(map.entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactC));
+
+ Runfiles.ManifestBuilder builder = new Runfiles.ManifestBuilder(
+ new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null),
+ PathFragment.EMPTY_FRAGMENT, false);
+
+ builder.put(runfilesPath(pathA), artifactB);
+ assertThat(builder.build().entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactB));
+ builder.put(runfilesPath(pathA), artifactC);
+ assertThat(builder.build().entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactC));
checkConflictWarning();
}
@@ -157,15 +168,15 @@ public class RunfilesTest extends FoundationTestCase {
PathFragment pathA = new PathFragment("a");
Artifact artifactB = new Artifact(new PathFragment("b"), root);
Artifact artifactC = new Artifact(new PathFragment("c"), root);
- Map<PathFragment, Artifact> map = new LinkedHashMap<>();
// Same as above but with ERROR not WARNING
- Runfiles.ConflictChecker checker =
- new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.ERROR, reporter, null);
- checker.put(map, pathA, artifactB);
+ Runfiles.ManifestBuilder builder = new Runfiles.ManifestBuilder(
+ new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.ERROR, reporter, null),
+ PathFragment.EMPTY_FRAGMENT, false);
+ builder.put(runfilesPath(pathA), artifactB);
reporter.removeHandler(failFastHandler); // So it doesn't throw AssertionError
- checker.put(map, pathA, artifactC);
- assertThat(map.entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactC));
+ builder.put(runfilesPath(pathA), artifactC);
+ assertThat(builder.build().entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactC));
checkConflictError();
}
@@ -174,13 +185,13 @@ public class RunfilesTest extends FoundationTestCase {
Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
PathFragment pathA = new PathFragment("a");
Artifact artifactB = new Artifact(new PathFragment("b"), root);
- Map<PathFragment, Artifact> map = new LinkedHashMap<>();
- Runfiles.ConflictChecker checker =
- new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null);
- checker.put(map, pathA, null);
- checker.put(map, pathA, artifactB);
- assertThat(map.entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactB));
+ Runfiles.ManifestBuilder builder = new Runfiles.ManifestBuilder(
+ new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null),
+ PathFragment.EMPTY_FRAGMENT, false);
+ builder.put(runfilesPath(pathA), null);
+ builder.put(runfilesPath(pathA), artifactB);
+ assertThat(builder.build().entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactB));
checkConflictWarning();
}
@@ -189,14 +200,14 @@ public class RunfilesTest extends FoundationTestCase {
Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
PathFragment pathA = new PathFragment("a");
Artifact artifactB = new Artifact(new PathFragment("b"), root);
- Map<PathFragment, Artifact> map = new LinkedHashMap<>();
// Same as above but opposite order
- Runfiles.ConflictChecker checker =
- new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null);
- checker.put(map, pathA, artifactB);
- checker.put(map, pathA, null);
- assertThat(map.entrySet()).containsExactly(Maps.immutableEntry(pathA, null));
+ Runfiles.ManifestBuilder builder = new Runfiles.ManifestBuilder(
+ new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null),
+ PathFragment.EMPTY_FRAGMENT, false);
+ builder.put(runfilesPath(pathA), artifactB);
+ builder.put(runfilesPath(pathA), null);
+ assertThat(builder.build().entrySet()).containsExactly(Maps.immutableEntry(pathA, null));
checkConflictWarning();
}
@@ -206,13 +217,13 @@ public class RunfilesTest extends FoundationTestCase {
PathFragment pathA = new PathFragment("a");
Artifact artifactB = new Artifact(new PathFragment("b"), root);
Artifact artifactC = new Artifact(new PathFragment("c"), root);
- Map<PathFragment, Artifact> map = new LinkedHashMap<>();
- Runfiles.ConflictChecker checker =
- new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.IGNORE, reporter, null);
- checker.put(map, pathA, artifactB);
- checker.put(map, pathA, artifactC);
- assertThat(map.entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactC));
+ Runfiles.ManifestBuilder builder = new Runfiles.ManifestBuilder(
+ new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.IGNORE, reporter, null),
+ PathFragment.EMPTY_FRAGMENT, false);
+ builder.put(runfilesPath(pathA), artifactB);
+ builder.put(runfilesPath(pathA), artifactC);
+ assertThat(builder.build().entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactC));
assertNoEvents();
}
@@ -222,13 +233,13 @@ public class RunfilesTest extends FoundationTestCase {
PathFragment pathA = new PathFragment("a");
Artifact artifactB = new Artifact(new PathFragment("b"), root);
Artifact artifactC = new Artifact(new PathFragment("c"), root);
- Map<PathFragment, Artifact> map = new LinkedHashMap<>();
- Runfiles.ConflictChecker checker =
- new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, null, null);
- checker.put(map, pathA, artifactB);
- checker.put(map, pathA, artifactC);
- assertThat(map.entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactC));
+ Runfiles.ManifestBuilder builder = new Runfiles.ManifestBuilder(
+ new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, null, null),
+ PathFragment.EMPTY_FRAGMENT, false);
+ builder.put(runfilesPath(pathA), artifactB);
+ builder.put(runfilesPath(pathA), artifactC);
+ assertThat(builder.build().entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactC));
assertNoEvents();
}
@@ -239,27 +250,27 @@ public class RunfilesTest extends FoundationTestCase {
Artifact artifactB = new Artifact(new PathFragment("b"), root);
Artifact artifactB2 = new Artifact(new PathFragment("b"), root);
assertEquals(artifactB, artifactB2);
- Map<PathFragment, Artifact> map = new LinkedHashMap<>();
- Runfiles.ConflictChecker checker =
- new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null);
- checker.put(map, pathA, artifactB);
- checker.put(map, pathA, artifactB2);
- assertThat(map.entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactB2));
+ Runfiles.ManifestBuilder builder = new Runfiles.ManifestBuilder(
+ new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null),
+ PathFragment.EMPTY_FRAGMENT, false);
+ builder.put(runfilesPath(pathA), artifactB);
+ builder.put(runfilesPath(pathA), artifactB2);
+ assertThat(builder.build().entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactB2));
assertNoEvents();
}
@Test
public void testPutIgnoresNullAndNull() {
PathFragment pathA = new PathFragment("a");
- Map<PathFragment, Artifact> map = new LinkedHashMap<>();
- Runfiles.ConflictChecker checker =
- new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null);
- checker.put(map, pathA, null);
+ Runfiles.ManifestBuilder builder = new Runfiles.ManifestBuilder(
+ new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null),
+ PathFragment.EMPTY_FRAGMENT, false);
+ builder.put(runfilesPath(pathA), null);
// Add it again
- checker.put(map, pathA, null);
- assertThat(map.entrySet()).containsExactly(Maps.immutableEntry(pathA, null));
+ builder.put(runfilesPath(pathA), null);
+ assertThat(builder.build().entrySet()).containsExactly(Maps.immutableEntry(pathA, null));
assertNoEvents();
}
@@ -271,16 +282,16 @@ public class RunfilesTest extends FoundationTestCase {
PathFragment pathC = new PathFragment("c");
Artifact artifactA = new Artifact(new PathFragment("a"), root);
Artifact artifactB = new Artifact(new PathFragment("b"), root);
- Map<PathFragment, Artifact> map = new LinkedHashMap<>();
- Runfiles.ConflictChecker checker =
- new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null);
- checker.put(map, pathA, artifactA);
+ Runfiles.ManifestBuilder builder = new Runfiles.ManifestBuilder(
+ new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null),
+ PathFragment.EMPTY_FRAGMENT, false);
+ builder.put(runfilesPath(pathA), artifactA);
// Add different artifact under different path
- checker.put(map, pathB, artifactB);
+ builder.put(runfilesPath(pathB), artifactB);
// Add artifact again under different path
- checker.put(map, pathC, artifactA);
- assertThat(map.entrySet())
+ builder.put(runfilesPath(pathC), artifactA);
+ assertThat(builder.build().entrySet())
.containsExactly(
Maps.immutableEntry(pathA, artifactA),
Maps.immutableEntry(pathB, artifactB),
@@ -291,29 +302,50 @@ public class RunfilesTest extends FoundationTestCase {
@Test
public void testBuilderMergeConflictPolicyDefault() {
- Runfiles r1 = new Runfiles.Builder("TESTING").build();
- Runfiles r2 = new Runfiles.Builder("TESTING").merge(r1).build();
+ Runfiles r1 = new Runfiles.Builder("TESTING", false).build();
+ Runfiles r2 = new Runfiles.Builder("TESTING", false).merge(r1).build();
assertEquals(Runfiles.ConflictPolicy.IGNORE, r2.getConflictPolicy());
}
@Test
public void testBuilderMergeConflictPolicyInherit() {
- Runfiles r1 = new Runfiles.Builder("TESTING").build()
+ Runfiles r1 = new Runfiles.Builder("TESTING", false).build()
.setConflictPolicy(Runfiles.ConflictPolicy.WARN);
- Runfiles r2 = new Runfiles.Builder("TESTING").merge(r1).build();
+ Runfiles r2 = new Runfiles.Builder("TESTING", false).merge(r1).build();
assertEquals(Runfiles.ConflictPolicy.WARN, r2.getConflictPolicy());
}
@Test
public void testBuilderMergeConflictPolicyInheritStrictest() {
- Runfiles r1 = new Runfiles.Builder("TESTING").build()
+ Runfiles r1 = new Runfiles.Builder("TESTING", false).build()
.setConflictPolicy(Runfiles.ConflictPolicy.WARN);
- Runfiles r2 = new Runfiles.Builder("TESTING").build()
+ Runfiles r2 = new Runfiles.Builder("TESTING", false).build()
.setConflictPolicy(Runfiles.ConflictPolicy.ERROR);
- Runfiles r3 = new Runfiles.Builder("TESTING").merge(r1).merge(r2).build();
+ Runfiles r3 = new Runfiles.Builder("TESTING", false).merge(r1).merge(r2).build();
assertEquals(Runfiles.ConflictPolicy.ERROR, r3.getConflictPolicy());
// Swap ordering
- Runfiles r4 = new Runfiles.Builder("TESTING").merge(r2).merge(r1).build();
+ Runfiles r4 = new Runfiles.Builder("TESTING", false).merge(r2).merge(r1).build();
assertEquals(Runfiles.ConflictPolicy.ERROR, r4.getConflictPolicy());
}
+
+ @Test
+ public void testLegacyRunfilesStructure() {
+ Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
+ PathFragment workspaceName = new PathFragment("wsname");
+ PathFragment pathB = new PathFragment("repo/b");
+ Artifact artifactB = new Artifact(pathB, root);
+
+ Runfiles.ManifestBuilder builder = new Runfiles.ManifestBuilder(
+ new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null),
+ workspaceName,
+ true);
+
+ builder.put(runfilesPath(pathB), artifactB);
+
+ assertThat(builder.build().entrySet()).containsExactly(
+ Maps.immutableEntry(workspaceName.getRelative(".runfile"), null),
+ Maps.immutableEntry(workspaceName.getRelative("external").getRelative(pathB), artifactB),
+ Maps.immutableEntry(pathB, artifactB));
+ assertNoEvents();
+ }
}
diff --git a/src/test/java/com/google/devtools/build/lib/cmdline/PackageIdentifierTest.java b/src/test/java/com/google/devtools/build/lib/cmdline/PackageIdentifierTest.java
index a2a133cb90..5d32df7f1b 100644
--- a/src/test/java/com/google/devtools/build/lib/cmdline/PackageIdentifierTest.java
+++ b/src/test/java/com/google/devtools/build/lib/cmdline/PackageIdentifierTest.java
@@ -99,4 +99,12 @@ public class PackageIdentifierTest {
PackageIdentifier p2 = PackageIdentifier.create("@whatever", new PathFragment("foo/bar"));
assertSame(p2.getPackageFragment(), p1.getPackageFragment());
}
+
+ @Test
+ public void testRunfilesDir() throws Exception {
+ assertThat(PackageIdentifier.create("@foo", new PathFragment("bar/baz")).getRunfilesPath())
+ .isEqualTo(new PathFragment("../foo/bar/baz"));
+ assertThat(PackageIdentifier.create("@", new PathFragment("bar/baz")).getRunfilesPath())
+ .isEqualTo(new PathFragment("bar/baz"));
+ }
}
diff --git a/src/test/java/com/google/devtools/build/lib/cmdline/RepositoryNameTest.java b/src/test/java/com/google/devtools/build/lib/cmdline/RepositoryNameTest.java
index b84af2fde6..9a39bbfda1 100644
--- a/src/test/java/com/google/devtools/build/lib/cmdline/RepositoryNameTest.java
+++ b/src/test/java/com/google/devtools/build/lib/cmdline/RepositoryNameTest.java
@@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+import com.google.devtools.build.lib.vfs.PathFragment;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -56,4 +57,14 @@ public class RepositoryNameTest {
assertNotValid("@foo\0", "workspace names may contain only A-Z, a-z, 0-9, '-', '_' and '.'");
}
+ @Test
+ public void testRunfilesDir() throws Exception {
+ assertThat(RepositoryName.create("@foo").getRunfilesPath())
+ .isEqualTo(new PathFragment("../foo"));
+ assertThat(RepositoryName.create("@").getRunfilesPath())
+ .isEqualTo(PathFragment.EMPTY_FRAGMENT);
+ assertThat(RepositoryName.create("").getRunfilesPath())
+ .isEqualTo(PathFragment.EMPTY_FRAGMENT);
+ }
+
}
diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/MockToolsConfig.java b/src/test/java/com/google/devtools/build/lib/packages/util/MockToolsConfig.java
index 6207fde742..8b57ff53dc 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/util/MockToolsConfig.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/util/MockToolsConfig.java
@@ -123,12 +123,12 @@ public final class MockToolsConfig {
*/
public void linkTool(String relativePath, String dest) throws IOException {
Preconditions.checkState(realFileSystem);
- Path target = runfilesDirectory.getRelative(TestConstants.RUNFILES_PREFIX + "/" + relativePath);
+ Path target = runfilesDirectory.getRelative(TestConstants.WORKSPACE_NAME + "/" + relativePath);
if (!target.exists()) {
// In some cases we run tests in a special client with a ../READONLY/ path where we may also
// find the runfiles. Try that, too.
Path readOnlyClientPath = rootDirectory.getRelative(
- "../READONLY/" + TestConstants.RUNFILES_PREFIX + "/" + relativePath);
+ "../READONLY/" + TestConstants.WORKSPACE_NAME + "/" + relativePath);
if (!readOnlyClientPath.exists()) {
throw new IOException("target does not exist " + target);
} else {
diff --git a/src/test/java/com/google/devtools/build/lib/testutil/TestConstants.java b/src/test/java/com/google/devtools/build/lib/testutil/TestConstants.java
index 6d4fb51bef..cab180b1a5 100644
--- a/src/test/java/com/google/devtools/build/lib/testutil/TestConstants.java
+++ b/src/test/java/com/google/devtools/build/lib/testutil/TestConstants.java
@@ -38,17 +38,12 @@ public class TestConstants {
* Location in the bazel repo where embedded binaries come from.
*/
public static final ImmutableList<String> EMBEDDED_SCRIPTS_PATHS = ImmutableList.of(
- "src/main/tools");
-
- /**
- * Path within runfiles tree for finding everything else.
- */
- public static final String RUNFILES_PREFIX = "DOES-NOT-WORK-YET";
+ "io_bazel/src/main/tools");
/**
* Default workspace name.
*/
- public static final String WORKSPACE_NAME = "";
+ public static final String WORKSPACE_NAME = "__main__";
/**
* Name of a class with an INSTANCE field of type AnalysisMock to be used for analysis tests.
@@ -59,7 +54,7 @@ public class TestConstants {
/**
* Directory where we can find bazel's Java tests, relative to a test's runfiles directory.
*/
- public static final String JAVATESTS_ROOT = "src/test/java/";
+ public static final String JAVATESTS_ROOT = "io_bazel/src/test/java/";
public static final String TEST_RULE_CLASS_PROVIDER =
"com.google.devtools.build.lib.bazel.rules.BazelRuleClassProvider";
diff --git a/src/test/shell/bazel/bazel_example_test.sh b/src/test/shell/bazel/bazel_example_test.sh
index b9d2aef276..93075fddb6 100755
--- a/src/test/shell/bazel/bazel_example_test.sh
+++ b/src/test/shell/bazel/bazel_example_test.sh
@@ -23,6 +23,9 @@ source $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/test-setup.sh \
function set_up() {
copy_examples
+ cat > WORKSPACE <<EOF
+workspace(name = "io_bazel")
+EOF
}
#
@@ -77,20 +80,6 @@ function test_java_test_with_junitrunner() {
assert_test_ok "${java_native_tests}:custom_with_test_class"
}
-function test_java_test_with_workspace_name() {
- local java_pkg=examples/java-native/src/main/java/com/example/myproject
- # Use named workspace and test if we can still execute hello-world
- bazel clean
-
- rm -f WORKSPACE
- cat >WORKSPACE <<'EOF'
-workspace(name = "toto")
-EOF
-
- assert_build_output ./bazel-bin/${java_pkg}/hello-world ${java_pkg}:hello-world
- assert_binary_run_from_subdir "bazel-bin/${java_pkg}/hello-world foo" "Hello foo"
-}
-
function test_genrule_and_genquery() {
# The --javabase flag is to force the tools/jdk:jdk label to be used
# so it appears in the dependency list.
diff --git a/src/test/shell/bazel/bazel_rules_test.sh b/src/test/shell/bazel/bazel_rules_test.sh
index b0f7e4e312..c82b9cd996 100755
--- a/src/test/shell/bazel/bazel_rules_test.sh
+++ b/src/test/shell/bazel/bazel_rules_test.sh
@@ -63,7 +63,7 @@ function test_extra_action() {
# a program that parses the proto here.
cat > mypkg/echoer.sh <<EOF
#!/bin/bash
-if [[ ! -e \$0.runfiles/mypkg/runfile ]]; then
+if [[ ! -e \$0.runfiles/__main__/mypkg/runfile ]]; then
echo "Runfile not found" >&2
exit 1
fi
@@ -357,8 +357,8 @@ def Fib(n):
EOF
cat > module2/bez.py <<EOF
-from external.remote.module_a import foo
-from external.remote.module_b import bar
+from remote.module_a import foo
+from remote.module_b import bar
from module1 import fib
print "The number is %d" % foo.GetNumber()
diff --git a/src/test/shell/bazel/bazel_sandboxing_test.sh b/src/test/shell/bazel/bazel_sandboxing_test.sh
index 27097bc9c1..9e6bc857d8 100755
--- a/src/test/shell/bazel/bazel_sandboxing_test.sh
+++ b/src/test/shell/bazel/bazel_sandboxing_test.sh
@@ -164,7 +164,7 @@ EOF
#!/bin/sh
set -e
-cp $(dirname $0)/tool.runfiles/examples/genrule/datafile $1
+cp $(dirname $0)/tool.runfiles/__main__/examples/genrule/datafile $1
echo "Tools work!"
EOF
chmod +x examples/genrule/tool.sh
diff --git a/src/test/shell/bazel/external_integration_test.sh b/src/test/shell/bazel/external_integration_test.sh
index 6f3a6b03c0..e9c1bc6660 100755
--- a/src/test/shell/bazel/external_integration_test.sh
+++ b/src/test/shell/bazel/external_integration_test.sh
@@ -139,7 +139,7 @@ EOF
cat > zoo/female.sh <<EOF
#!/bin/bash
-./external/endangered/fox/male
+../endangered/fox/male
EOF
chmod +x zoo/female.sh
fi
@@ -422,10 +422,10 @@ EOF
cat > test/test.sh <<EOF
#!/bin/bash
echo "symlink:"
-ls -l external/toto/file
+ls -l ../toto/file
echo "dest:"
-ls -l \$(readlink -f external/toto/file/toto)
-external/toto/file/toto
+ls -l \$(readlink -f ../toto/file/toto)
+../toto/file/toto
EOF
chmod +x test/test.sh
@@ -459,7 +459,7 @@ EOF
cat > test/test.sh <<EOF
#!/bin/bash
-cat external/toto/file/toto
+cat ../toto/file/toto
EOF
chmod +x test/test.sh
@@ -581,7 +581,7 @@ EOF
cat > zoo/female.sh <<EOF
#!/bin/bash
-cat external/endangered/fox/male
+cat ../endangered/fox/male
EOF
chmod +x zoo/female.sh
diff --git a/src/test/shell/bazel/generate_workspace_test.sh b/src/test/shell/bazel/generate_workspace_test.sh
index 18168459c9..584f3e04d8 100755
--- a/src/test/shell/bazel/generate_workspace_test.sh
+++ b/src/test/shell/bazel/generate_workspace_test.sh
@@ -24,8 +24,6 @@ source $src_dir/test-setup.sh \
source $src_dir/remote_helpers.sh \
|| { echo "remote_helpers.sh not found!" >&2; exit 1; }
-export JAVA_RUNFILES=$TEST_SRCDIR
-
function set_up() {
# Set up custom repository directory.
m2=$TEST_TMPDIR/my-m2
diff --git a/src/test/shell/bazel/git_repository_test.sh b/src/test/shell/bazel/git_repository_test.sh
index 67a630dd1b..2c862b7f7e 100755
--- a/src/test/shell/bazel/git_repository_test.sh
+++ b/src/test/shell/bazel/git_repository_test.sh
@@ -85,7 +85,7 @@ EOF
cat > planets/planet_info.sh <<EOF
#!/bin/bash
-cat external/pluto/info
+cat ../pluto/info
EOF
chmod +x planets/planet_info.sh
@@ -171,7 +171,7 @@ EOF
cat > planets/planet_info.sh <<EOF
#!/bin/bash
-cat external/pluto/info
+cat ../pluto/info
EOF
chmod +x planets/planet_info.sh
@@ -246,8 +246,8 @@ EOF
cat > planets/planet_info.sh <<EOF
#!/bin/bash
-cat external/outer_planets/neptune/info
-cat external/outer_planets/pluto/info
+cat ../outer_planets/neptune/info
+cat ../outer_planets/pluto/info
EOF
chmod +x planets/planet_info.sh
diff --git a/src/test/shell/bazel/local_repository_test.sh b/src/test/shell/bazel/local_repository_test.sh
index 0fad9c95f0..70f9be6769 100755
--- a/src/test/shell/bazel/local_repository_test.sh
+++ b/src/test/shell/bazel/local_repository_test.sh
@@ -95,7 +95,7 @@ EOF
cat > zoo/dumper.sh <<EOF
#!/bin/bash
-cat external/pandas/red/baby-panda
+cat ../pandas/red/baby-panda
cat red/day-keeper
EOF
chmod +x zoo/dumper.sh
diff --git a/src/test/shell/bazel/testenv.sh b/src/test/shell/bazel/testenv.sh
index 14c39c0766..8820f93a6e 100755
--- a/src/test/shell/bazel/testenv.sh
+++ b/src/test/shell/bazel/testenv.sh
@@ -18,6 +18,7 @@
#
[ -z "$TEST_SRCDIR" ] && { echo "TEST_SRCDIR not set!" >&2; exit 1; }
+TEST_SRCDIR="$TEST_SRCDIR/io_bazel"
# Load the unit-testing framework
source "${TEST_SRCDIR}/src/test/shell/unittest.bash" || \
@@ -29,7 +30,7 @@ bazel="${TEST_SRCDIR}/src/bazel"
bazel_data="${TEST_SRCDIR}"
# Java
-jdk_dir="${TEST_SRCDIR}/external/local_jdk"
+jdk_dir="${TEST_SRCDIR}/../local_jdk"
langtools="${TEST_SRCDIR}/src/test/shell/bazel/langtools.jar"
# Tools directory location
diff --git a/src/test/shell/integration/runfiles_test.sh b/src/test/shell/integration/runfiles_test.sh
index 6821b30dcd..ee26ca130c 100755
--- a/src/test/shell/integration/runfiles_test.sh
+++ b/src/test/shell/integration/runfiles_test.sh
@@ -55,16 +55,16 @@ EOF
bazel build pkg:py >&$TEST_log 2>&1 || fail "build failed"
# we get a warning that hidden.py is inaccessible
- expect_log_once "/genfiles/pkg/e/f/g/hidden.py obscured by pkg/e/f "
+ expect_log_once "/genfiles/pkg/e/f/g/hidden.py obscured by .*/pkg/e/f "
}
function test_foo_runfiles() {
-cat > BUILD << EOF
+ cat > BUILD << EOF
py_library(name = "root",
srcs = ["__init__.py"],
visibility = ["//visibility:public"])
EOF
-cat > pkg/BUILD << EOF
+ cat > pkg/BUILD << EOF
sh_binary(name = "foo",
srcs = [ "x/y/z.sh" ],
data = [ ":py",
@@ -149,4 +149,3 @@ EOF
}
run_suite "runfiles"
-