aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar Damien Martin-Guillerez <dmarting@google.com>2016-04-22 11:42:34 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-04-22 11:53:26 +0000
commit9e4c78fb5752fa554db82815f7336255831a95ab (patch)
treefdf498cf18c1e875fc4be3d00afb5f99583ee1a9 /src/test
parent8ed31f05e664e925ad628ab47feeaaab30c26283 (diff)
*** Reason for rollback *** Broke non-Bazel projects on ci.bazel.io Fixes #1168 *** Original change description *** 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.... *** -- MOS_MIGRATED_REVID=120535721
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/runfiles_test.sh39
-rwxr-xr-xsrc/test/shell/bazel/testenv.sh3
-rwxr-xr-xsrc/test/shell/integration/runfiles_test.sh7
16 files changed, 143 insertions, 215 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 70024c460e..8626f6913e 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", false).addArtifacts(artifacts).build();
+ return new Runfiles.Builder("TESTING").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 ef2373f6ae..7b806f371d 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,13 +22,16 @@ 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}.
*/
@@ -42,92 +45,79 @@ 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);
- 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())
+ obscuringMap.put(pathA, artifactA);
+ obscuringMap.put(new PathFragment("a/b"), new Artifact(new PathFragment("c/b"),
+ root));
+ assertThat(Runfiles.filterListForObscuringSymlinks(reporter, null, obscuringMap).entrySet())
.containsExactly(Maps.immutableEntry(pathA, artifactA)).inOrder();
checkWarning();
}
@Test
public void testFilterListForObscuringSymlinksCatchesBadGrandParentObscurer() throws Exception {
- Runfiles.ManifestBuilder obscuringMap = new Runfiles.ManifestBuilder(
- null, PathFragment.EMPTY_FRAGMENT, false);
+ 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(runfilesPath("a"), artifactA);
- obscuringMap.put(runfilesPath("a/b/c"), new Artifact(new PathFragment("b/c"), root));
- assertThat(obscuringMap.filterListForObscuringSymlinks(reporter, null).build().entrySet())
+ 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())
.containsExactly(Maps.immutableEntry(pathA, artifactA)).inOrder();
checkWarning();
}
@Test
public void testFilterListForObscuringSymlinksCatchesBadObscurerNoListener() throws Exception {
- Runfiles.ManifestBuilder obscuringMap = new Runfiles.ManifestBuilder(
- null, PathFragment.EMPTY_FRAGMENT, false);
+ 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(runfilesPath("a"), artifactA);
- obscuringMap.put(runfilesPath("a/b"), new Artifact(new PathFragment("c/b"), root));
- assertThat(obscuringMap.filterListForObscuringSymlinks(null, null).build().entrySet())
+ obscuringMap.put(pathA, artifactA);
+ obscuringMap.put(new PathFragment("a/b"), new Artifact(new PathFragment("c/b"),
+ root));
+ assertThat(Runfiles.filterListForObscuringSymlinks(null, null, obscuringMap).entrySet())
.containsExactly(Maps.immutableEntry(pathA, artifactA)).inOrder();
}
@Test
public void testFilterListForObscuringSymlinksIgnoresOkObscurer() throws Exception {
- Runfiles.ManifestBuilder obscuringMap = new Runfiles.ManifestBuilder(
- null, PathFragment.EMPTY_FRAGMENT, false);
+ 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(runfilesPath("a"), artifactA);
- obscuringMap.put(runfilesPath("a/b"), new Artifact(new PathFragment("a/b"), root));
+ obscuringMap.put(pathA, artifactA);
+ obscuringMap.put(new PathFragment("a/b"), new Artifact(new PathFragment("a/b"),
+ root));
- assertThat(obscuringMap.filterListForObscuringSymlinks(reporter, null).build().entrySet())
+ assertThat(Runfiles.filterListForObscuringSymlinks(reporter, null, obscuringMap).entrySet())
.containsExactly(Maps.immutableEntry(pathA, artifactA)).inOrder();
assertNoEvents();
}
@Test
public void testFilterListForObscuringSymlinksNoObscurers() throws Exception {
- Runfiles.ManifestBuilder obscuringMap = new Runfiles.ManifestBuilder(
- null, PathFragment.EMPTY_FRAGMENT, false);
+ 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(
- Runfiles.RunfilesPath.alreadyResolved(
- pathA, new PathFragment(TestConstants.WORKSPACE_NAME)),
- artifactA);
+ obscuringMap.put(pathA, artifactA);
PathFragment pathBC = new PathFragment("b/c");
Artifact artifactBC = new Artifact(new PathFragment("a/b"),
root);
- obscuringMap.put(runfilesPath(pathBC), artifactBC);
- assertThat(obscuringMap.filterListForObscuringSymlinks(reporter, null).build()
- .entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactA),
+ obscuringMap.put(pathBC, artifactBC);
+ assertThat(Runfiles.filterListForObscuringSymlinks(reporter, null, obscuringMap)
+ .entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactA),
Maps.immutableEntry(pathBC, artifactBC));
assertNoEvents();
}
@@ -150,15 +140,14 @@ 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);
-
- 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));
+ 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));
checkConflictWarning();
}
@@ -168,15 +157,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.ManifestBuilder builder = new Runfiles.ManifestBuilder(
- new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.ERROR, reporter, null),
- PathFragment.EMPTY_FRAGMENT, false);
- builder.put(runfilesPath(pathA), artifactB);
+ Runfiles.ConflictChecker checker =
+ new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.ERROR, reporter, null);
+ checker.put(map, pathA, artifactB);
reporter.removeHandler(failFastHandler); // So it doesn't throw AssertionError
- builder.put(runfilesPath(pathA), artifactC);
- assertThat(builder.build().entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactC));
+ checker.put(map, pathA, artifactC);
+ assertThat(map.entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactC));
checkConflictError();
}
@@ -185,13 +174,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.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));
+ 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));
checkConflictWarning();
}
@@ -200,14 +189,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.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));
+ 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));
checkConflictWarning();
}
@@ -217,13 +206,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.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));
+ 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));
assertNoEvents();
}
@@ -233,13 +222,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.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));
+ 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));
assertNoEvents();
}
@@ -250,27 +239,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.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));
+ 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));
assertNoEvents();
}
@Test
public void testPutIgnoresNullAndNull() {
PathFragment pathA = new PathFragment("a");
+ Map<PathFragment, Artifact> map = new LinkedHashMap<>();
- Runfiles.ManifestBuilder builder = new Runfiles.ManifestBuilder(
- new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null),
- PathFragment.EMPTY_FRAGMENT, false);
- builder.put(runfilesPath(pathA), null);
+ Runfiles.ConflictChecker checker =
+ new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null);
+ checker.put(map, pathA, null);
// Add it again
- builder.put(runfilesPath(pathA), null);
- assertThat(builder.build().entrySet()).containsExactly(Maps.immutableEntry(pathA, null));
+ checker.put(map, pathA, null);
+ assertThat(map.entrySet()).containsExactly(Maps.immutableEntry(pathA, null));
assertNoEvents();
}
@@ -282,16 +271,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.ManifestBuilder builder = new Runfiles.ManifestBuilder(
- new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null),
- PathFragment.EMPTY_FRAGMENT, false);
- builder.put(runfilesPath(pathA), artifactA);
+ Runfiles.ConflictChecker checker =
+ new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.WARN, reporter, null);
+ checker.put(map, pathA, artifactA);
// Add different artifact under different path
- builder.put(runfilesPath(pathB), artifactB);
+ checker.put(map, pathB, artifactB);
// Add artifact again under different path
- builder.put(runfilesPath(pathC), artifactA);
- assertThat(builder.build().entrySet())
+ checker.put(map, pathC, artifactA);
+ assertThat(map.entrySet())
.containsExactly(
Maps.immutableEntry(pathA, artifactA),
Maps.immutableEntry(pathB, artifactB),
@@ -302,50 +291,29 @@ public class RunfilesTest extends FoundationTestCase {
@Test
public void testBuilderMergeConflictPolicyDefault() {
- Runfiles r1 = new Runfiles.Builder("TESTING", false).build();
- Runfiles r2 = new Runfiles.Builder("TESTING", false).merge(r1).build();
+ Runfiles r1 = new Runfiles.Builder("TESTING").build();
+ Runfiles r2 = new Runfiles.Builder("TESTING").merge(r1).build();
assertEquals(Runfiles.ConflictPolicy.IGNORE, r2.getConflictPolicy());
}
@Test
public void testBuilderMergeConflictPolicyInherit() {
- Runfiles r1 = new Runfiles.Builder("TESTING", false).build()
+ Runfiles r1 = new Runfiles.Builder("TESTING").build()
.setConflictPolicy(Runfiles.ConflictPolicy.WARN);
- Runfiles r2 = new Runfiles.Builder("TESTING", false).merge(r1).build();
+ Runfiles r2 = new Runfiles.Builder("TESTING").merge(r1).build();
assertEquals(Runfiles.ConflictPolicy.WARN, r2.getConflictPolicy());
}
@Test
public void testBuilderMergeConflictPolicyInheritStrictest() {
- Runfiles r1 = new Runfiles.Builder("TESTING", false).build()
+ Runfiles r1 = new Runfiles.Builder("TESTING").build()
.setConflictPolicy(Runfiles.ConflictPolicy.WARN);
- Runfiles r2 = new Runfiles.Builder("TESTING", false).build()
+ Runfiles r2 = new Runfiles.Builder("TESTING").build()
.setConflictPolicy(Runfiles.ConflictPolicy.ERROR);
- Runfiles r3 = new Runfiles.Builder("TESTING", false).merge(r1).merge(r2).build();
+ Runfiles r3 = new Runfiles.Builder("TESTING").merge(r1).merge(r2).build();
assertEquals(Runfiles.ConflictPolicy.ERROR, r3.getConflictPolicy());
// Swap ordering
- Runfiles r4 = new Runfiles.Builder("TESTING", false).merge(r2).merge(r1).build();
+ Runfiles r4 = new Runfiles.Builder("TESTING").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 5d32df7f1b..a2a133cb90 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,12 +99,4 @@ 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 9a39bbfda1..b84af2fde6 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,7 +18,6 @@ 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;
@@ -57,14 +56,4 @@ 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 8b57ff53dc..6207fde742 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.WORKSPACE_NAME + "/" + relativePath);
+ Path target = runfilesDirectory.getRelative(TestConstants.RUNFILES_PREFIX + "/" + 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.WORKSPACE_NAME + "/" + relativePath);
+ "../READONLY/" + TestConstants.RUNFILES_PREFIX + "/" + 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 cab180b1a5..6d4fb51bef 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,12 +38,17 @@ public class TestConstants {
* Location in the bazel repo where embedded binaries come from.
*/
public static final ImmutableList<String> EMBEDDED_SCRIPTS_PATHS = ImmutableList.of(
- "io_bazel/src/main/tools");
+ "src/main/tools");
+
+ /**
+ * Path within runfiles tree for finding everything else.
+ */
+ public static final String RUNFILES_PREFIX = "DOES-NOT-WORK-YET";
/**
* Default workspace name.
*/
- public static final String WORKSPACE_NAME = "__main__";
+ public static final String WORKSPACE_NAME = "";
/**
* Name of a class with an INSTANCE field of type AnalysisMock to be used for analysis tests.
@@ -54,7 +59,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 = "io_bazel/src/test/java/";
+ public static final String JAVATESTS_ROOT = "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 93075fddb6..b9d2aef276 100755
--- a/src/test/shell/bazel/bazel_example_test.sh
+++ b/src/test/shell/bazel/bazel_example_test.sh
@@ -23,9 +23,6 @@ source $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/test-setup.sh \
function set_up() {
copy_examples
- cat > WORKSPACE <<EOF
-workspace(name = "io_bazel")
-EOF
}
#
@@ -80,6 +77,20 @@ 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 c82b9cd996..b0f7e4e312 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/__main__/mypkg/runfile ]]; then
+if [[ ! -e \$0.runfiles/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 remote.module_a import foo
-from remote.module_b import bar
+from external.remote.module_a import foo
+from external.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 9e6bc857d8..27097bc9c1 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/__main__/examples/genrule/datafile $1
+cp $(dirname $0)/tool.runfiles/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 e9c1bc6660..6f3a6b03c0 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
-../endangered/fox/male
+./external/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 ../toto/file
+ls -l external/toto/file
echo "dest:"
-ls -l \$(readlink -f ../toto/file/toto)
-../toto/file/toto
+ls -l \$(readlink -f external/toto/file/toto)
+external/toto/file/toto
EOF
chmod +x test/test.sh
@@ -459,7 +459,7 @@ EOF
cat > test/test.sh <<EOF
#!/bin/bash
-cat ../toto/file/toto
+cat external/toto/file/toto
EOF
chmod +x test/test.sh
@@ -581,7 +581,7 @@ EOF
cat > zoo/female.sh <<EOF
#!/bin/bash
-cat ../endangered/fox/male
+cat external/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 584f3e04d8..18168459c9 100755
--- a/src/test/shell/bazel/generate_workspace_test.sh
+++ b/src/test/shell/bazel/generate_workspace_test.sh
@@ -24,6 +24,8 @@ 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 2c862b7f7e..67a630dd1b 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 ../pluto/info
+cat external/pluto/info
EOF
chmod +x planets/planet_info.sh
@@ -171,7 +171,7 @@ EOF
cat > planets/planet_info.sh <<EOF
#!/bin/bash
-cat ../pluto/info
+cat external/pluto/info
EOF
chmod +x planets/planet_info.sh
@@ -246,8 +246,8 @@ EOF
cat > planets/planet_info.sh <<EOF
#!/bin/bash
-cat ../outer_planets/neptune/info
-cat ../outer_planets/pluto/info
+cat external/outer_planets/neptune/info
+cat external/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 d078cadba3..d2ba764726 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 ../pandas/red/baby-panda
+cat external/pandas/red/baby-panda
cat red/day-keeper
EOF
chmod +x zoo/dumper.sh
diff --git a/src/test/shell/bazel/runfiles_test.sh b/src/test/shell/bazel/runfiles_test.sh
index 698f319d59..33205b86d2 100755
--- a/src/test/shell/bazel/runfiles_test.sh
+++ b/src/test/shell/bazel/runfiles_test.sh
@@ -53,43 +53,4 @@ EOF
[[ -x bazel-bin/foo/foo.runfiles/$name/foo/foo ]] || fail "No foo executable under $name"
}
-function test_external_runfiles() {
- cat > WORKSPACE <<EOF
-workspace(name = "foo")
-
-new_local_repository(
- name = "bar",
- path = ".",
- build_file = "BUILD",
-)
-EOF
-
- cat > BUILD <<EOF
-exports_files(glob(["*"]))
-
-cc_binary(
- name = "thing",
- srcs = ["thing.cc"],
- data = ["@bar//:thing.cc"],
-)
-EOF
- cat > thing.cc <<EOF
-int main() { return 0; }
-EOF
- bazel build --legacy_external_runfiles //:thing &> $TEST_log \
- || fail "Build failed"
- [[ -d bazel-bin/thing.runfiles/foo/external/bar ]] \
- || fail "bar not found"
-
- bazel build --nolegacy_external_runfiles //:thing &> $TEST_log \
- || fail "Build failed"
- [[ ! -d bazel-bin/thing.runfiles/foo/external/bar ]] \
- || fail "Old bar still found"
-
- bazel build --legacy_external_runfiles //:thing &> $TEST_log \
- || fail "Build failed"
- [[ -d bazel-bin/thing.runfiles/foo/external/bar ]] \
- || fail "bar not recreated"
-}
-
run_suite "runfiles tests"
diff --git a/src/test/shell/bazel/testenv.sh b/src/test/shell/bazel/testenv.sh
index 4db59d358e..5689de846e 100755
--- a/src/test/shell/bazel/testenv.sh
+++ b/src/test/shell/bazel/testenv.sh
@@ -18,7 +18,6 @@
#
[ -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" || \
@@ -30,7 +29,7 @@ bazel="${TEST_SRCDIR}/src/bazel"
bazel_data="${TEST_SRCDIR}"
# Java
-jdk_dir="${TEST_SRCDIR}/../local_jdk"
+jdk_dir="${TEST_SRCDIR}/external/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 ee26ca130c..6821b30dcd 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,3 +149,4 @@ EOF
}
run_suite "runfiles"
+