use of com.google.devtools.build.lib.actions.util.TestAction in project bazel by bazelbuild.
the class ParallelBuilderTest method testReportsActionExecutedEvent.
@Test
public void testReportsActionExecutedEvent() throws Exception {
Artifact pear = createDerivedArtifact("pear");
ActionEventRecorder recorder = new ActionEventRecorder();
EventBus eventBus = new EventBus();
eventBusRef.set(eventBus);
eventBus.register(recorder);
Action action = registerAction(new TestAction(Runnables.doNothing(), emptySet, asSet(pear)));
buildArtifacts(createBuilder(DEFAULT_NUM_JOBS, true), pear);
assertThat(recorder.actionExecutedEvents).hasSize(1);
assertEquals(action, recorder.actionExecutedEvents.get(0).getAction());
}
use of com.google.devtools.build.lib.actions.util.TestAction in project bazel by bazelbuild.
the class ParallelBuilderTest method testUpdateCacheError.
@Test
public void testUpdateCacheError() throws Exception {
FileSystem fs = new InMemoryFileSystem() {
@Override
public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
final FileStatus stat = super.stat(path, followSymlinks);
if (path.toString().endsWith("/out/foo")) {
return new FileStatus() {
private final FileStatus original = stat;
@Override
public boolean isSymbolicLink() {
return original.isSymbolicLink();
}
@Override
public boolean isFile() {
return original.isFile();
}
@Override
public boolean isDirectory() {
return original.isDirectory();
}
@Override
public boolean isSpecialFile() {
return original.isSpecialFile();
}
@Override
public long getSize() throws IOException {
return original.getSize();
}
@Override
public long getNodeId() throws IOException {
return original.getNodeId();
}
@Override
public long getLastModifiedTime() throws IOException {
throw new IOException();
}
@Override
public long getLastChangeTime() throws IOException {
return original.getLastChangeTime();
}
};
}
return stat;
}
};
Artifact foo = createDerivedArtifact(fs, "foo");
registerAction(new TestAction(TestAction.NO_EFFECT, emptySet, ImmutableList.of(foo)));
reporter.removeHandler(failFastHandler);
try {
buildArtifacts(foo);
fail("Expected to fail");
} catch (BuildFailedException e) {
assertContainsEvent("not all outputs were created or valid");
}
}
use of com.google.devtools.build.lib.actions.util.TestAction in project bazel by bazelbuild.
the class ParallelBuilderTest method testCyclicActionGraph.
@Test
public void testCyclicActionGraph() throws Exception {
// foo -> [action] -> bar
// bar -> [action] -> baz
// baz -> [action] -> foo
Artifact foo = createDerivedArtifact("foo");
Artifact bar = createDerivedArtifact("bar");
Artifact baz = createDerivedArtifact("baz");
try {
registerAction(new TestAction(TestAction.NO_EFFECT, asSet(foo), asSet(bar)));
registerAction(new TestAction(TestAction.NO_EFFECT, asSet(bar), asSet(baz)));
registerAction(new TestAction(TestAction.NO_EFFECT, asSet(baz), asSet(foo)));
buildArtifacts(foo);
fail("Builder failed to detect cyclic action graph");
} catch (BuildFailedException e) {
assertEquals(e.getMessage(), CYCLE_MSG);
}
}
use of com.google.devtools.build.lib.actions.util.TestAction in project bazel by bazelbuild.
the class ParallelBuilderTest method testSelfCyclicActionGraph.
@Test
public void testSelfCyclicActionGraph() throws Exception {
// foo -> [action] -> foo
Artifact foo = createDerivedArtifact("foo");
try {
registerAction(new TestAction(TestAction.NO_EFFECT, asSet(foo), asSet(foo)));
buildArtifacts(foo);
fail("Builder failed to detect cyclic action graph");
} catch (BuildFailedException e) {
assertEquals(e.getMessage(), CYCLE_MSG);
}
}
use of com.google.devtools.build.lib.actions.util.TestAction in project bazel by bazelbuild.
the class TimestampBuilderTestCase method createActionCounter.
/**
* Creates a TestAction from 'inputs' to 'outputs', and a new counter, such
* that executing the action causes the counter to be incremented. The
* counter is returned.
*/
protected Counter createActionCounter(Collection<Artifact> inputs, Collection<Artifact> outputs) {
Counter counter = new Counter();
registerAction(new TestAction(counter, inputs, outputs));
return counter;
}
Aggregations