aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2016-09-30 14:16:29 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-10-04 08:52:56 +0000
commit96c047c430c1569fdfc649de358b34aeaff1f6bb (patch)
treeeede9d4db91c96be387f36093bf143660f0c5cf3 /src/test/java/com/google/devtools/build/lib
parenta6b4cbbd4a4bbb42eefe8fb0e646cd30780394e4 (diff)
cc_inc_library deletes its output directory before execution.
This ensures that stale outputs from prior builds do not remain to confuse the compiler. Fixes #1778. -- Change-Id: I31b5c3e7e5970cf45c3ff10144ddfc73540ef9af Reviewed-on: https://bazel-review.googlesource.com/6250 MOS_MIGRATED_REVID=134780501
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/actions/CreateIncSymlinkActionTest.java32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/CreateIncSymlinkActionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/CreateIncSymlinkActionTest.java
index 2ff8f70372..9f5b2540f1 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/actions/CreateIncSymlinkActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/CreateIncSymlinkActionTest.java
@@ -29,7 +29,6 @@ import com.google.devtools.build.lib.testutil.TestSpec;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.Symlinks;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -49,14 +48,14 @@ public class CreateIncSymlinkActionTest extends FoundationTestCase {
Artifact c = new Artifact(new PathFragment("c"), root);
Artifact d = new Artifact(new PathFragment("d"), root);
CreateIncSymlinkAction action1 = new CreateIncSymlinkAction(NULL_ACTION_OWNER,
- ImmutableMap.of(a, b, c, d));
+ ImmutableMap.of(a, b, c, d), root.getPath());
// Can't reuse the artifacts here; that would lead to DuplicateArtifactException.
a = new Artifact(new PathFragment("a"), root);
b = new Artifact(new PathFragment("b"), root);
c = new Artifact(new PathFragment("c"), root);
d = new Artifact(new PathFragment("d"), root);
CreateIncSymlinkAction action2 = new CreateIncSymlinkAction(NULL_ACTION_OWNER,
- ImmutableMap.of(c, d, a, b));
+ ImmutableMap.of(c, d, a, b), root.getPath());
assertEquals(action1.computeKey(), action2.computeKey());
}
@@ -66,12 +65,12 @@ public class CreateIncSymlinkActionTest extends FoundationTestCase {
Artifact a = new Artifact(new PathFragment("a"), root);
Artifact b = new Artifact(new PathFragment("b"), root);
CreateIncSymlinkAction action1 = new CreateIncSymlinkAction(NULL_ACTION_OWNER,
- ImmutableMap.of(a, b));
+ ImmutableMap.of(a, b), root.getPath());
// Can't reuse the artifacts here; that would lead to DuplicateArtifactException.
a = new Artifact(new PathFragment("a"), root);
b = new Artifact(new PathFragment("c"), root);
CreateIncSymlinkAction action2 = new CreateIncSymlinkAction(NULL_ACTION_OWNER,
- ImmutableMap.of(a, b));
+ ImmutableMap.of(a, b), root.getPath());
assertThat(action2.computeKey()).isNotEqualTo(action1.computeKey());
}
@@ -81,12 +80,12 @@ public class CreateIncSymlinkActionTest extends FoundationTestCase {
Artifact a = new Artifact(new PathFragment("a"), root);
Artifact b = new Artifact(new PathFragment("b"), root);
CreateIncSymlinkAction action1 = new CreateIncSymlinkAction(NULL_ACTION_OWNER,
- ImmutableMap.of(a, b));
+ ImmutableMap.of(a, b), root.getPath());
// Can't reuse the artifacts here; that would lead to DuplicateArtifactException.
a = new Artifact(new PathFragment("c"), root);
b = new Artifact(new PathFragment("b"), root);
CreateIncSymlinkAction action2 = new CreateIncSymlinkAction(NULL_ACTION_OWNER,
- ImmutableMap.of(a, b));
+ ImmutableMap.of(a, b), root.getPath());
assertThat(action2.computeKey()).isNotEqualTo(action1.computeKey());
}
@@ -99,11 +98,28 @@ public class CreateIncSymlinkActionTest extends FoundationTestCase {
Artifact a = new Artifact(symlink, root);
Artifact b = new Artifact(new PathFragment("b"), root);
CreateIncSymlinkAction action = new CreateIncSymlinkAction(NULL_ACTION_OWNER,
- ImmutableMap.of(a, b));
+ ImmutableMap.of(a, b), outputDir);
action.execute(null);
symlink.stat(Symlinks.NOFOLLOW);
assertTrue(symlink.isSymbolicLink());
assertEquals(symlink.readSymbolicLink(), b.getPath().asFragment());
assertFalse(rootDirectory.getRelative("a").exists());
}
+
+ @Test
+ public void testFileRemoved() throws Exception {
+ Path outputDir = rootDirectory.getRelative("out");
+ outputDir.createDirectory();
+ Root root = Root.asDerivedRoot(rootDirectory, outputDir);
+ Path symlink = rootDirectory.getRelative("out/subdir/a");
+ Artifact a = new Artifact(symlink, root);
+ Artifact b = new Artifact(new PathFragment("b"), root);
+ CreateIncSymlinkAction action =
+ new CreateIncSymlinkAction(NULL_ACTION_OWNER, ImmutableMap.of(a, b), outputDir);
+ Path extra = rootDirectory.getRelative("out/extra");
+ extra.getOutputStream().close();
+ assertTrue(extra.exists());
+ action.prepare(rootDirectory);
+ assertFalse(extra.exists());
+ }
}