Search in sources :

Example 1 with LoadingPhaseStartedEvent

use of com.google.devtools.build.lib.skyframe.LoadingPhaseStartedEvent in project bazel by bazelbuild.

the class ExperimentalStateTrackerTest method testLoadingActivity.

@Test
public void testLoadingActivity() throws IOException {
    // During loading phase, state and activity, as reported by the PackageProgressReceiver,
    // should be visible in the progress bar.
    String state = "42 packages loaded";
    String activity = "currently loading //src/foo/bar and 17 more";
    PackageProgressReceiver progress = Mockito.mock(PackageProgressReceiver.class);
    when(progress.progressState()).thenReturn(new Pair<String, String>(state, activity));
    ManualClock clock = new ManualClock();
    ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock);
    stateTracker.loadingStarted(new LoadingPhaseStartedEvent(progress));
    LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/
    true);
    stateTracker.writeProgressBar(terminalWriter);
    String output = terminalWriter.getTranscript();
    assertTrue("Output should indicate that we are in the loading phase, but was:\n" + output, output.contains("Loading"));
    assertTrue("Output should contain loading state '" + state + "', but was:\n" + output, output.contains(state));
    assertTrue("Output should contain loading state '" + activity + "', but was:\n" + output, output.contains(activity));
}
Also used : ManualClock(com.google.devtools.build.lib.testutil.ManualClock) PackageProgressReceiver(com.google.devtools.build.lib.skyframe.PackageProgressReceiver) LoggingTerminalWriter(com.google.devtools.build.lib.util.io.LoggingTerminalWriter) LoadingPhaseStartedEvent(com.google.devtools.build.lib.skyframe.LoadingPhaseStartedEvent) Test(org.junit.Test)

Aggregations

LoadingPhaseStartedEvent (com.google.devtools.build.lib.skyframe.LoadingPhaseStartedEvent)1 PackageProgressReceiver (com.google.devtools.build.lib.skyframe.PackageProgressReceiver)1 ManualClock (com.google.devtools.build.lib.testutil.ManualClock)1 LoggingTerminalWriter (com.google.devtools.build.lib.util.io.LoggingTerminalWriter)1 Test (org.junit.Test)1