use of com.google.devtools.build.lib.skyframe.DiffAwarenessManager.ProcessableModifiedFileSet in project bazel by bazelbuild.
the class DiffAwarenessManagerTest method testHandlesBrokenDiffs.
@Test
public void testHandlesBrokenDiffs() throws Exception {
Path pathEntry = root.getRelative("pathEntry");
DiffAwarenessFactoryStub factory1 = new DiffAwarenessFactoryStub();
DiffAwarenessStub diffAwareness1 = new DiffAwarenessStub(ImmutableList.<ModifiedFileSet>of(), 1);
factory1.inject(pathEntry, diffAwareness1);
DiffAwarenessFactoryStub factory2 = new DiffAwarenessFactoryStub();
ModifiedFileSet diff2 = ModifiedFileSet.builder().modify(new PathFragment("file2")).build();
DiffAwarenessStub diffAwareness2 = new DiffAwarenessStub(ImmutableList.of(diff2, DiffAwarenessStub.BROKEN_DIFF));
factory2.inject(pathEntry, diffAwareness2);
DiffAwarenessFactoryStub factory3 = new DiffAwarenessFactoryStub();
ModifiedFileSet diff3 = ModifiedFileSet.builder().modify(new PathFragment("file3")).build();
DiffAwarenessStub diffAwareness3 = new DiffAwarenessStub(ImmutableList.of(diff3));
factory3.inject(pathEntry, diffAwareness3);
DiffAwarenessManager manager = new DiffAwarenessManager(ImmutableList.of(factory1, factory2, factory3));
ProcessableModifiedFileSet processableDiff = manager.getDiff(events.reporter(), pathEntry, OptionsClassProvider.EMPTY);
events.assertNoWarningsOrErrors();
assertEquals("Expected EVERYTHING_MODIFIED on first call to getDiff for diffAwareness1", ModifiedFileSet.EVERYTHING_MODIFIED, processableDiff.getModifiedFileSet());
processableDiff.markProcessed();
processableDiff = manager.getDiff(events.reporter(), pathEntry, OptionsClassProvider.EMPTY);
events.assertContainsEventWithFrequency("error in getCurrentView", 1);
assertEquals("Expected EVERYTHING_MODIFIED because of broken getCurrentView", ModifiedFileSet.EVERYTHING_MODIFIED, processableDiff.getModifiedFileSet());
processableDiff.markProcessed();
factory1.remove(pathEntry);
processableDiff = manager.getDiff(events.reporter(), pathEntry, OptionsClassProvider.EMPTY);
assertEquals("Expected EVERYTHING_MODIFIED on first call to getDiff for diffAwareness2", ModifiedFileSet.EVERYTHING_MODIFIED, processableDiff.getModifiedFileSet());
processableDiff.markProcessed();
processableDiff = manager.getDiff(events.reporter(), pathEntry, OptionsClassProvider.EMPTY);
assertEquals(diff2, processableDiff.getModifiedFileSet());
processableDiff.markProcessed();
processableDiff = manager.getDiff(events.reporter(), pathEntry, OptionsClassProvider.EMPTY);
events.assertContainsEventWithFrequency("error in getDiff", 1);
assertEquals("Expected EVERYTHING_MODIFIED because of broken getDiff", ModifiedFileSet.EVERYTHING_MODIFIED, processableDiff.getModifiedFileSet());
processableDiff.markProcessed();
factory2.remove(pathEntry);
processableDiff = manager.getDiff(events.reporter(), pathEntry, OptionsClassProvider.EMPTY);
assertEquals("Expected EVERYTHING_MODIFIED on first call to getDiff for diffAwareness3", ModifiedFileSet.EVERYTHING_MODIFIED, processableDiff.getModifiedFileSet());
processableDiff.markProcessed();
processableDiff = manager.getDiff(events.reporter(), pathEntry, OptionsClassProvider.EMPTY);
assertEquals(diff3, processableDiff.getModifiedFileSet());
processableDiff.markProcessed();
}
use of com.google.devtools.build.lib.skyframe.DiffAwarenessManager.ProcessableModifiedFileSet in project bazel by bazelbuild.
the class DiffAwarenessManagerTest method testHandlesUnprocessedDiffs.
@Test
public void testHandlesUnprocessedDiffs() throws Exception {
Path pathEntry = root.getRelative("pathEntry");
ModifiedFileSet diff1 = ModifiedFileSet.builder().modify(new PathFragment("file1")).build();
ModifiedFileSet diff2 = ModifiedFileSet.builder().modify(new PathFragment("file2")).build();
ModifiedFileSet diff3 = ModifiedFileSet.builder().modify(new PathFragment("file3")).build();
DiffAwarenessStub diffAwareness = new DiffAwarenessStub(ImmutableList.of(diff1, diff2, diff3, DiffAwarenessStub.BROKEN_DIFF));
DiffAwarenessFactoryStub factory = new DiffAwarenessFactoryStub();
factory.inject(pathEntry, diffAwareness);
DiffAwarenessManager manager = new DiffAwarenessManager(ImmutableList.of(factory));
ProcessableModifiedFileSet firstProcessableDiff = manager.getDiff(events.reporter(), pathEntry, OptionsClassProvider.EMPTY);
assertEquals("Expected EVERYTHING_MODIFIED on first call to getDiff", ModifiedFileSet.EVERYTHING_MODIFIED, firstProcessableDiff.getModifiedFileSet());
firstProcessableDiff.markProcessed();
ProcessableModifiedFileSet processableDiff1 = manager.getDiff(events.reporter(), pathEntry, OptionsClassProvider.EMPTY);
assertEquals(diff1, processableDiff1.getModifiedFileSet());
ProcessableModifiedFileSet processableDiff2 = manager.getDiff(events.reporter(), pathEntry, OptionsClassProvider.EMPTY);
assertEquals(ModifiedFileSet.union(diff1, diff2), processableDiff2.getModifiedFileSet());
processableDiff2.markProcessed();
ProcessableModifiedFileSet processableDiff3 = manager.getDiff(events.reporter(), pathEntry, OptionsClassProvider.EMPTY);
assertEquals(diff3, processableDiff3.getModifiedFileSet());
events.assertNoWarningsOrErrors();
ProcessableModifiedFileSet processableDiff4 = manager.getDiff(events.reporter(), pathEntry, OptionsClassProvider.EMPTY);
assertEquals(ModifiedFileSet.EVERYTHING_MODIFIED, processableDiff4.getModifiedFileSet());
events.assertContainsWarning("error");
}
Aggregations