diff options
author | 2017-02-17 14:48:48 +0000 | |
---|---|---|
committer | 2017-02-17 14:57:32 +0000 | |
commit | e36a66cd6e35e5b4b276f2b6ce63e1c691bcb02c (patch) | |
tree | 7d2b273bf2948aa350147a91da3a6b4ad0111e34 /src/test/java/com/google/devtools/build/lib/analysis | |
parent | 75639985d593f683ba13d2ceb38ec310662fb56b (diff) |
Rollback of commit 4b73e972d909bcd533f2f9940f95a00b9b73bdde.
*** Reason for rollback ***
Broke tests on CI: http://ci.bazel.io/job/bazel-tests/570/
*** Original change description ***
Roll forward execroot change
RELNOTES[INC]: Previously, an external repository would be symlinked into the
execution root at execroot/local_repo/external/remote_repo. This changes it to
be at execroot/remote_repo. This may break genrules/Skylark actions that
hardcode execution root paths. If this causes breakages for you, ensure that
genrules are using $(location :target) to access files and Skylark rules are
using http://bazel.io/docs/skylark/lib/File.html's path, dirname, etc.
functions. Cust...
--
PiperOrigin-RevId: 147833177
MOS_MIGRATED_REVID=147833177
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/analysis')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java | 45 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java | 3 |
2 files changed, 37 insertions, 11 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 2c18fd38a1..f6d1509bb1 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); @@ -358,6 +362,31 @@ public class RunfilesTest extends FoundationTestCase { 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(); + } + @Test public void testMergeWithSymlinks() { Root root = Root.asSourceRoot(scratch.resolve("/workspace")); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java index cecd220d9d..03128110d4 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java @@ -38,7 +38,6 @@ import com.google.devtools.build.lib.analysis.config.ConfigurationFactory; import com.google.devtools.build.lib.buildtool.BuildRequest.BuildRequestOptions; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.LabelSyntaxException; -import com.google.devtools.build.lib.cmdline.PackageIdentifier; import com.google.devtools.build.lib.exec.ExecutionOptions; import com.google.devtools.build.lib.flags.InvocationPolicyEnforcer; import com.google.devtools.build.lib.packages.PackageFactory; @@ -199,8 +198,6 @@ public abstract class AnalysisTestCase extends FoundationTestCase { loadingPhaseRunner = skyframeExecutor.getLoadingPhaseRunner( pkgFactory.getRuleClassNames(), defaultFlags().contains(Flag.SKYFRAME_LOADING_PHASE)); buildView = new BuildView(directories, ruleClassProvider, skyframeExecutor, null); - buildView.setArtifactRoots( - ImmutableMap.of(PackageIdentifier.createInMainRepo(""), rootDirectory)); useConfiguration(); } |