Search in sources :

Example 1 with NotComparableStringValue

use of com.google.devtools.build.skyframe.GraphTester.NotComparableStringValue in project bazel by bazelbuild.

the class MemoizingEvaluatorTest method checkNotComparableNotPruned.

private void checkNotComparableNotPruned(boolean hasEvent) throws Exception {
    initializeTester();
    SkyKey parent = GraphTester.toSkyKey("parent");
    SkyKey child = GraphTester.toSkyKey("child");
    NotComparableStringValue notComparableString = new NotComparableStringValue("not comparable");
    if (hasEvent) {
        tester.getOrCreate(child).setConstantValue(notComparableString).setWarning("shmoop");
    } else {
        tester.getOrCreate(child).setConstantValue(notComparableString);
    }
    final AtomicInteger parentEvaluated = new AtomicInteger();
    final String val = "some val";
    tester.getOrCreate(parent).addDependency(child).setComputedValue(new ValueComputer() {

        @Override
        public SkyValue compute(Map<SkyKey, SkyValue> deps, Environment env) throws InterruptedException {
            parentEvaluated.incrementAndGet();
            return new StringValue(val);
        }
    });
    assertStringValue(val, tester.evalAndGet(/*keepGoing=*/
    false, parent));
    assertThat(parentEvaluated.get()).isEqualTo(1);
    if (hasEvent) {
        assertContainsEvent(eventCollector, "shmoop");
    } else {
        assertEventCount(0, eventCollector);
    }
    tester.resetPlayedEvents();
    tester.getOrCreate(child, /*markAsModified=*/
    true);
    tester.invalidate();
    assertStringValue(val, tester.evalAndGet(/*keepGoing=*/
    false, parent));
    assertThat(parentEvaluated.get()).isEqualTo(2);
    if (hasEvent) {
        assertContainsEvent(eventCollector, "shmoop");
    } else {
        assertEventCount(0, eventCollector);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NotComparableStringValue(com.google.devtools.build.skyframe.GraphTester.NotComparableStringValue) Environment(com.google.devtools.build.skyframe.SkyFunction.Environment) NotComparableStringValue(com.google.devtools.build.skyframe.GraphTester.NotComparableStringValue) StringValue(com.google.devtools.build.skyframe.GraphTester.StringValue) ValueComputer(com.google.devtools.build.skyframe.GraphTester.ValueComputer)

Aggregations

NotComparableStringValue (com.google.devtools.build.skyframe.GraphTester.NotComparableStringValue)1 StringValue (com.google.devtools.build.skyframe.GraphTester.StringValue)1 ValueComputer (com.google.devtools.build.skyframe.GraphTester.ValueComputer)1 Environment (com.google.devtools.build.skyframe.SkyFunction.Environment)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1