use of com.google.devtools.build.lib.actions.Artifact in project bazel by bazelbuild.
the class TimestampBuilderTest method testBuildingTransitivePrerequisites.
@Test
public void testBuildingTransitivePrerequisites() throws Exception {
// hello -> [action1] -> wazuup -> [action2] -> goodbye
Artifact hello = createSourceArtifact("hello");
BlazeTestUtils.makeEmptyFile(hello.getPath());
Artifact wazuup = createDerivedArtifact("wazuup");
Button button1 = new Button();
registerAction(new CopyingAction(button1, hello, wazuup));
Artifact goodbye = createDerivedArtifact("goodbye");
Button button2 = createActionButton(Sets.newHashSet(wazuup), Sets.newHashSet(goodbye));
button1.pressed = button2.pressed = false;
buildArtifacts(cachingBuilder(), wazuup);
// built wazuup
assertTrue(button1.pressed);
// goodbye not built
assertFalse(button2.pressed);
button1.pressed = button2.pressed = false;
buildArtifacts(cachingBuilder(), wazuup);
// wazuup not rebuilt
assertFalse(button1.pressed);
// goodbye not built
assertFalse(button2.pressed);
button1.pressed = button2.pressed = false;
buildArtifacts(cachingBuilder(), goodbye);
// wazuup not rebuilt
assertFalse(button1.pressed);
// built goodbye
assertTrue(button2.pressed);
button1.pressed = button2.pressed = false;
buildArtifacts(cachingBuilder(), goodbye);
// wazuup not rebuilt
assertFalse(button1.pressed);
// goodbye not rebuilt
assertFalse(button2.pressed);
hello.getPath().setWritable(true);
FileSystemUtils.writeContentAsLatin1(hello.getPath(), "new content");
button1.pressed = button2.pressed = false;
buildArtifacts(cachingBuilder(), goodbye);
// hello rebuilt
assertTrue(button1.pressed);
// goodbye rebuilt
assertTrue(button2.pressed);
}
use of com.google.devtools.build.lib.actions.Artifact in project bazel by bazelbuild.
the class TimestampBuilderTest method testModifyingInputCausesActionReexecution.
@Test
public void testModifyingInputCausesActionReexecution() throws Exception {
// hello -> [action] -> goodbye
Artifact hello = createSourceArtifact("hello");
BlazeTestUtils.makeEmptyFile(hello.getPath());
Artifact goodbye = createDerivedArtifact("goodbye");
Button button = createActionButton(Sets.newHashSet(hello), Sets.newHashSet(goodbye));
button.pressed = false;
buildArtifacts(cachingBuilder(), goodbye);
// built
assertTrue(button.pressed);
button.pressed = false;
buildArtifacts(cachingBuilder(), goodbye);
// not rebuilt
assertFalse(button.pressed);
hello.getPath().setWritable(true);
FileSystemUtils.writeContentAsLatin1(hello.getPath(), "new content");
button.pressed = false;
buildArtifacts(cachingBuilder(), goodbye);
// rebuilt
assertTrue(button.pressed);
button.pressed = false;
buildArtifacts(cachingBuilder(), goodbye);
// not rebuilt
assertFalse(button.pressed);
}
use of com.google.devtools.build.lib.actions.Artifact in project bazel by bazelbuild.
the class TimestampBuilderTest method testCachingBuilderCachesUntilReset.
@Test
public void testCachingBuilderCachesUntilReset() throws Exception {
// [action] -> hello
Artifact hello = createDerivedArtifact("hello");
Button button = createActionButton(emptySet, Sets.newHashSet(hello));
button.pressed = false;
buildArtifacts(cachingBuilder(), hello);
// built
assertTrue(button.pressed);
button.pressed = false;
buildArtifacts(cachingBuilder(), hello);
// not rebuilt
assertFalse(button.pressed);
inMemoryCache.reset();
button.pressed = false;
buildArtifacts(cachingBuilder(), hello);
// rebuilt
assertTrue(button.pressed);
}
use of com.google.devtools.build.lib.actions.Artifact in project bazel by bazelbuild.
the class TimestampBuilderTest method testModifyingOutputCausesActionReexecution.
@Test
public void testModifyingOutputCausesActionReexecution() throws Exception {
// [action] -> hello
Artifact hello = createDerivedArtifact("hello");
Button button = createActionButton(emptySet, Sets.newHashSet(hello));
button.pressed = false;
buildArtifacts(cachingBuilder(), hello);
// built
assertTrue(button.pressed);
button.pressed = false;
buildArtifacts(cachingBuilder(), hello);
// not rebuilt
assertFalse(button.pressed);
// Changing the *output* file 'hello' causes 'action' to re-execute, to make things consistent
// again.
hello.getPath().setWritable(true);
FileSystemUtils.writeContentAsLatin1(hello.getPath(), "new content");
button.pressed = false;
buildArtifacts(cachingBuilder(), hello);
// rebuilt
assertTrue(button.pressed);
button.pressed = false;
buildArtifacts(cachingBuilder(), hello);
// not rebuilt
assertFalse(button.pressed);
}
use of com.google.devtools.build.lib.actions.Artifact in project bazel by bazelbuild.
the class TimestampBuilderTestCase method createDerivedArtifact.
Artifact createDerivedArtifact(FileSystem fs, String name) {
Path execRoot = fs.getPath(TestUtils.tmpDir());
PathFragment execPath = new PathFragment("out").getRelative(name);
Path path = execRoot.getRelative(execPath);
return new Artifact(path, Root.asDerivedRoot(execRoot, execRoot.getRelative("out")), execPath, ALL_OWNER);
}
Aggregations