Search in sources :

Example 1 with SingleCycleReporter

use of com.google.devtools.build.skyframe.CyclesReporter.SingleCycleReporter in project bazel by bazelbuild.

the class CyclesReporterTest method smoke.

@Test
public void smoke() {
    final AtomicBoolean reported = new AtomicBoolean();
    SingleCycleReporter singleReporter = new SingleCycleReporter() {

        @Override
        public boolean maybeReportCycle(SkyKey topLevelKey, CycleInfo cycleInfo, boolean alreadyReported, ExtendedEventHandler eventHandler) {
            reported.set(true);
            return true;
        }
    };
    CycleInfo cycleInfo = new CycleInfo(ImmutableList.of(DUMMY_KEY));
    CyclesReporter cyclesReporter = new CyclesReporter(singleReporter);
    cyclesReporter.reportCycles(ImmutableList.of(cycleInfo), DUMMY_KEY, NullEventHandler.INSTANCE);
    assertThat(reported.get()).isTrue();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SingleCycleReporter(com.google.devtools.build.skyframe.CyclesReporter.SingleCycleReporter) ExtendedEventHandler(com.google.devtools.build.lib.events.ExtendedEventHandler) Test(org.junit.Test)

Example 2 with SingleCycleReporter

use of com.google.devtools.build.skyframe.CyclesReporter.SingleCycleReporter in project bazel by bazelbuild.

the class CyclesReporterTest method notReportedAssertion.

@Test
public void notReportedAssertion() {
    SingleCycleReporter singleReporter = new SingleCycleReporter() {

        @Override
        public boolean maybeReportCycle(SkyKey topLevelKey, CycleInfo cycleInfo, boolean alreadyReported, ExtendedEventHandler eventHandler) {
            return false;
        }
    };
    CycleInfo cycleInfo = new CycleInfo(ImmutableList.of(DUMMY_KEY));
    CyclesReporter cyclesReporter = new CyclesReporter(singleReporter);
    try {
        cyclesReporter.reportCycles(ImmutableList.of(cycleInfo), DUMMY_KEY, NullEventHandler.INSTANCE);
        assertThat(false).isTrue();
    } catch (IllegalStateException e) {
    // Expected.
    }
}
Also used : SingleCycleReporter(com.google.devtools.build.skyframe.CyclesReporter.SingleCycleReporter) ExtendedEventHandler(com.google.devtools.build.lib.events.ExtendedEventHandler) Test(org.junit.Test)

Aggregations

ExtendedEventHandler (com.google.devtools.build.lib.events.ExtendedEventHandler)2 SingleCycleReporter (com.google.devtools.build.skyframe.CyclesReporter.SingleCycleReporter)2 Test (org.junit.Test)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1