diff options
Diffstat (limited to 'src/test/java/com/google/devtools')
6 files changed, 153 insertions, 107 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"; |