use of com.google.devtools.build.lib.actions.Artifact in project bazel by bazelbuild.
the class TimestampBuilderTest method testUnneededInputs.
@Test
public void testUnneededInputs() throws Exception {
Artifact hello = createSourceArtifact("hello");
BlazeTestUtils.makeEmptyFile(hello.getPath());
Artifact optional = createSourceArtifact("hello.optional");
Artifact goodbye = createDerivedArtifact("goodbye");
Button button = createActionButton(Sets.newHashSet(hello, optional), Sets.newHashSet(goodbye));
button.pressed = false;
buildArtifacts(cachingBuilder(), goodbye);
// built
assertTrue(button.pressed);
button.pressed = false;
buildArtifacts(cachingBuilder(), goodbye);
// not rebuilt
assertFalse(button.pressed);
BlazeTestUtils.makeEmptyFile(optional.getPath());
button.pressed = false;
buildArtifacts(cachingBuilder(), goodbye);
// built
assertTrue(button.pressed);
button.pressed = false;
buildArtifacts(cachingBuilder(), goodbye);
// not rebuilt
assertFalse(button.pressed);
optional.getPath().delete();
button.pressed = false;
buildArtifacts(cachingBuilder(), goodbye);
// built
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 testOnlyModifyingInputContentCausesReexecution.
@Test
public void testOnlyModifyingInputContentCausesReexecution() throws Exception {
// hello -> [action] -> goodbye
Artifact hello = createSourceArtifact("hello");
// touch file to create the directory structure
BlazeTestUtils.makeEmptyFile(hello.getPath());
FileSystemUtils.writeContentAsLatin1(hello.getPath(), "content1");
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);
FileSystemUtils.touchFile(hello.getPath());
button.pressed = false;
buildArtifacts(cachingBuilder(), goodbye);
// still not rebuilt
assertFalse(button.pressed);
FileSystemUtils.writeContentAsLatin1(hello.getPath(), "content2");
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 testBuildingNonexistentSourcefileFails.
@Test
public void testBuildingNonexistentSourcefileFails() throws Exception {
reporter.removeHandler(failFastHandler);
Artifact hello = createSourceArtifact("hello");
try {
buildArtifacts(cachingBuilder(), hello);
fail("Expected input file to be missing");
} catch (BuildFailedException e) {
assertThat(e).hasMessage("missing input file '" + hello.getPath() + "'");
}
}
use of com.google.devtools.build.lib.actions.Artifact in project bazel by bazelbuild.
the class TimestampBuilderTest method testWillNotRebuildActionsWithEmptyListOfInputsSpuriously.
@Test
public void testWillNotRebuildActionsWithEmptyListOfInputsSpuriously() throws Exception {
Artifact anOutputFile = createDerivedArtifact("anOutputFile");
Artifact anotherOutputFile = createDerivedArtifact("anotherOutputFile");
Collection<Artifact> noInputs = Collections.emptySet();
Button aButton = createActionButton(noInputs, Sets.newHashSet(anOutputFile));
Button anotherButton = createActionButton(noInputs, Sets.newHashSet(anotherOutputFile));
buildArtifacts(cachingBuilder(), anOutputFile, anotherOutputFile);
assertTrue(aButton.pressed);
assertTrue(anotherButton.pressed);
aButton.pressed = anotherButton.pressed = false;
buildArtifacts(cachingBuilder(), anOutputFile, anotherOutputFile);
assertFalse(aButton.pressed);
assertFalse(anotherButton.pressed);
}
use of com.google.devtools.build.lib.actions.Artifact in project bazel by bazelbuild.
the class TimestampBuilderTest method testAmnesiacBuilderAlwaysRebuilds.
@Test
public void testAmnesiacBuilderAlwaysRebuilds() throws Exception {
// [action] -> hello
Artifact hello = createDerivedArtifact("hello");
Button button = createActionButton(emptySet, Sets.newHashSet(hello));
button.pressed = false;
buildArtifacts(amnesiacBuilder(), hello);
// built
assertTrue(button.pressed);
button.pressed = false;
buildArtifacts(amnesiacBuilder(), hello);
// rebuilt
assertTrue(button.pressed);
}
Aggregations