aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2015-12-03 12:47:25 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2015-12-03 18:37:53 +0000
commit84fb4612dd4203425b59809ea5e3302ff55723fa (patch)
tree34aecc25c3e0a1493b6a8ad730312776b42c55d6 /src/test/java/com/google/devtools/build
parent912743f116833513f315e39058b213cb9f86b2f9 (diff)
Fileset: add a positive assertion (no symlink exclusion) to existing tests.
This change ensures that the symlink is excluded because it was in the exclusion set, not because its target is missing or any other reason. -- MOS_MIGRATED_REVID=109295933
Diffstat (limited to 'src/test/java/com/google/devtools/build')
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java
index abb006c829..81c0bf4b15 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java
@@ -644,22 +644,44 @@ public final class FilesetEntryFunctionTest extends FoundationTestCaseForJunit4
}
private void assertExclusionOfDanglingSymlink(SymlinkBehavior symlinkBehavior) throws Exception {
- Artifact linkName = getSourceArtifact("foo/dangling.sym");
Artifact buildFile = getSourceArtifact("foo/BUILD");
- RootedPath linkTarget = createFile(siblingOf(linkName, "target.file"), "blah");
- linkName.getPath().createSymbolicLink(new PathFragment("target.file"));
createFile(buildFile);
- linkTarget.asPath().delete();
- FilesetTraversalParams paramsWithSymlinkCopy =
+ Artifact linkName = getSourceArtifact("foo/file.sym");
+ Artifact linkTarget = getSourceArtifact("foo/file.actual");
+ createFile(linkTarget);
+ linkName.getPath().createSymbolicLink(new PathFragment("file.actual"));
+
+ // Ensure the symlink and its target would be included if they weren't explicitly excluded.
+ FilesetTraversalParams params =
+ FilesetTraversalParamsFactory.recursiveTraversalOfPackage(
+ /* ownerLabel */ label("//foo"),
+ /* buildFile */ buildFile,
+ /* destPath */ new PathFragment("output-name"),
+ /* excludes */ ImmutableSet.<String>of(),
+ /* symlinkBehaviorMode */ symlinkBehavior,
+ /* pkgBoundaryMode */ PackageBoundaryMode.DONT_CROSS);
+ assertSymlinksInOrder(
+ params,
+ symlink("output-name/BUILD", buildFile),
+ symlink("output-name/file.actual", linkTarget),
+ symlinkBehavior == SymlinkBehavior.COPY
+ ? symlink("output-name/file.sym", "file.actual")
+ : symlink("output-name/file.sym", linkTarget));
+
+ // Delete the symlink's target to make it dangling.
+ // Exclude the symlink and make sure it's not included.
+ linkTarget.getPath().delete();
+ differencer.invalidate(ImmutableList.of(FileStateValue.key(rootedPath(linkTarget))));
+ params =
FilesetTraversalParamsFactory.recursiveTraversalOfPackage(
/* ownerLabel */ label("//foo"),
/* buildFile */ buildFile,
/* destPath */ new PathFragment("output-name"),
- /* excludes */ ImmutableSet.of("dangling.sym"),
+ /* excludes */ ImmutableSet.of("file.sym"),
/* symlinkBehaviorMode */ symlinkBehavior,
/* pkgBoundaryMode */ PackageBoundaryMode.DONT_CROSS);
- assertSymlinksInOrder(paramsWithSymlinkCopy, symlink("output-name/BUILD", buildFile));
+ assertSymlinksInOrder(params, symlink("output-name/BUILD", buildFile));
}
@Test