use of com.google.devtools.build.lib.testutil.ManualClock in project bazel by bazelbuild.
the class ExperimentalStateTrackerTest method testSensibleShortening.
@Test
public void testSensibleShortening() throws Exception {
// Verify that in the typical case, we shorten the progress message by shortening
// the path implicit in it, that can also be extracted from the label. In particular,
// the parts
ManualClock clock = new ManualClock();
ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock, 70);
Action action = mockAction("Building some/very/very/long/path/for/some/library/directory/foo.jar (42 source files)", "/home/user/bazel/out/abcdef/some/very/very/long/path/for/some/library/directory/foo.jar");
Label label = Label.parseAbsolute("//some/very/very/long/path/for/some/library/directory:libfoo");
ActionOwner owner = ActionOwner.create(label, ImmutableList.<AspectDescriptor>of(), null, null, null, "fedcba", null);
when(action.getOwner()).thenReturn(owner);
clock.advanceMillis(TimeUnit.SECONDS.toMillis(3));
stateTracker.actionStarted(new ActionStartedEvent(action, clock.nanoTime()));
clock.advanceMillis(TimeUnit.SECONDS.toMillis(5));
LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/
true);
stateTracker.writeProgressBar(terminalWriter);
String output = terminalWriter.getTranscript();
assertTrue("Progress bar should contain 'Building ', but was:\n" + output, output.contains("Building "));
assertTrue("Progress bar should contain 'foo.jar (42 source files)', but was:\n" + output, output.contains("foo.jar (42 source files)"));
}
use of com.google.devtools.build.lib.testutil.ManualClock in project bazel by bazelbuild.
the class ExperimentalStateTrackerTest method doTestOutputLength.
private void doTestOutputLength(boolean withTest, int actions) throws Exception {
// If we target 70 characters, then there should be enough space to both,
// keep the line limit, and show the local part of the running actions and
// the passed test.
ManualClock clock = new ManualClock();
ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock, 70);
Action foobuildAction = mockAction("Building //src/some/very/long/path/long/long/long/long/long/long/long/foo/foobuild.jar", "//src/some/very/long/path/long/long/long/long/long/long/long/foo:foobuild");
Action bazbuildAction = mockAction("Building //src/some/very/long/path/long/long/long/long/long/long/long/baz/bazbuild.jar", "//src/some/very/long/path/long/long/long/long/long/long/long/baz:bazbuild");
Label bartestLabel = Label.parseAbsolute("//src/another/very/long/long/path/long/long/long/long/long/long/long/long/bars:bartest");
ConfiguredTarget bartestTarget = Mockito.mock(ConfiguredTarget.class);
when(bartestTarget.getLabel()).thenReturn(bartestLabel);
TestFilteringCompleteEvent filteringComplete = Mockito.mock(TestFilteringCompleteEvent.class);
when(filteringComplete.getTestTargets()).thenReturn(ImmutableSet.of(bartestTarget));
TestSummary testSummary = Mockito.mock(TestSummary.class);
when(testSummary.getStatus()).thenReturn(BlazeTestStatus.PASSED);
when(testSummary.getTarget()).thenReturn(bartestTarget);
if (actions >= 1) {
stateTracker.actionStarted(new ActionStartedEvent(foobuildAction, 123456789));
}
if (actions >= 2) {
stateTracker.actionStarted(new ActionStartedEvent(bazbuildAction, 123456900));
}
if (withTest) {
stateTracker.testFilteringComplete(filteringComplete);
stateTracker.testSummary(testSummary);
}
LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/
true);
stateTracker.writeProgressBar(terminalWriter);
String output = terminalWriter.getTranscript();
assertTrue("Only lines with at most 70 chars should be present in the output:\n" + output, longestLine(output) <= 70);
if (actions >= 1) {
assertTrue("Running action 'foobuild' should be mentioned in output:\n" + output, output.contains("foobuild"));
}
if (actions >= 2) {
assertTrue("Running action 'bazbuild' should be mentioned in output:\n" + output, output.contains("bazbuild"));
}
if (withTest) {
assertTrue("Passed test ':bartest' should be mentioned in output:\n" + output, output.contains(":bartest"));
}
}
use of com.google.devtools.build.lib.testutil.ManualClock in project bazel by bazelbuild.
the class FileSystemUtilsTest method initializeFileSystem.
@Before
public final void initializeFileSystem() throws Exception {
clock = new ManualClock();
fileSystem = new InMemoryFileSystem(clock);
workingDir = fileSystem.getPath("/workingDir");
workingDir.createDirectory();
}
use of com.google.devtools.build.lib.testutil.ManualClock in project bazel by bazelbuild.
the class SymlinkForestTest method initializeFileSystem.
@Before
public final void initializeFileSystem() throws Exception {
ManualClock clock = new ManualClock();
fileSystem = new InMemoryFileSystem(clock);
linkRoot = fileSystem.getPath("/linkRoot");
createDirectoryAndParents(linkRoot);
}
use of com.google.devtools.build.lib.testutil.ManualClock in project bazel by bazelbuild.
the class ExperimentalStateTrackerTest method testActionVisible.
@Test
public void testActionVisible() throws IOException {
// If there is only one action running, it should be visible
// somewhere in the progress bar, and also the short version thereof.
String message = "Building foo";
ManualClock clock = new ManualClock();
clock.advanceMillis(120000);
ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock);
stateTracker.actionStarted(new ActionStartedEvent(mockAction(message, "bar/foo"), 123456789));
LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/
true);
stateTracker.writeProgressBar(terminalWriter);
String output = terminalWriter.getTranscript();
assertTrue("Action message '" + message + "' should be present in output: " + output, output.contains(message));
terminalWriter = new LoggingTerminalWriter();
stateTracker.writeProgressBar(terminalWriter, /* shortVersion=*/
true);
output = terminalWriter.getTranscript();
assertTrue("Action message '" + message + "' should be present in short output: " + output, output.contains(message));
}
Aggregations