use of com.facebook.buck.event.BuckEvent in project buck by facebook.
the class UnskippedRulesTrackerTest method assertNoNewEvents.
private void assertNoNewEvents() throws InterruptedException {
// BuckEventBus is asynchronous so it is not enough to check that the events queue is empty.
// Instead, post a fake event and check that there were no pending events before it.
BuckEvent sentinel = new FakeEvent();
eventBus.post(sentinel);
assertThat("An event was received but no event was expected", events.take(), is(sameInstance(sentinel)));
}
use of com.facebook.buck.event.BuckEvent in project buck by facebook.
the class UnskippedRulesTrackerTest method setUp.
@Before
public void setUp() {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
sourcePathResolver = new SourcePathResolver(ruleFinder);
ListeningExecutorService executor = listeningDecorator(MostExecutors.newMultiThreadExecutor("UnskippedRulesTracker", 7));
RuleDepsCache depsCache = new RuleDepsCache(executor, resolver);
unskippedRulesTracker = new UnskippedRulesTracker(depsCache, resolver, executor);
eventBus = new BuckEventBus(new FakeClock(1), new BuildId());
eventBus.register(new Object() {
@Subscribe
public void onUnskippedRuleCountUpdated(BuckEvent event) {
events.add(event);
}
});
ruleH = resolver.addToIndex(createRule("//:h"));
ruleG = resolver.addToIndex(createRule("//:g"));
ruleF = resolver.addToIndex(createRule("//:f"));
ruleE = resolver.addToIndex(createRule("//:e", ImmutableSet.of(ruleG, ruleH)));
ruleD = resolver.addToIndex(createRule("//:d", ImmutableSet.of(ruleG), ImmutableSet.of(ruleF)));
ruleC = resolver.addToIndex(createRule("//:c", ImmutableSet.of(ruleD, ruleE)));
ruleB = resolver.addToIndex(createRule("//:b", ImmutableSet.of(), ImmutableSet.of(ruleD)));
ruleA = resolver.addToIndex(createRule("//:a", ImmutableSet.of(ruleD)));
}
use of com.facebook.buck.event.BuckEvent in project buck by facebook.
the class BuckEventOrdererTest method testPreservesInsertionOrderForSameTimestamp.
@Test
public void testPreservesInsertionOrderForSameTimestamp() {
BuckEvent first = createUniqueEvent(0, TimeUnit.MILLISECONDS, THREAD_ONE);
BuckEvent second = createUniqueEvent(0, TimeUnit.MILLISECONDS, THREAD_ONE);
BuckEvent third = createUniqueEvent(0, TimeUnit.MILLISECONDS, THREAD_ONE);
try (BuckEventOrderer<BuckEvent> orderer = new BuckEventOrderer<>(addToSerializedEventsFunction, MAX_SKEW, TimeUnit.MILLISECONDS)) {
orderer.add(first);
orderer.add(second);
orderer.add(third);
}
assertThat(serializedEvents, Matchers.contains(first, second, third));
}
use of com.facebook.buck.event.BuckEvent in project buck by facebook.
the class BuckEventOrdererTest method testPreservesInsertionOrderForSameTimestampWithReorder.
@Test
public void testPreservesInsertionOrderForSameTimestampWithReorder() {
BuckEvent first = createUniqueEvent(1, TimeUnit.MILLISECONDS, THREAD_ONE);
BuckEvent second = createUniqueEvent(2, TimeUnit.MILLISECONDS, THREAD_ONE);
BuckEvent third = createUniqueEvent(2, TimeUnit.MILLISECONDS, THREAD_ONE);
BuckEvent fourth = createUniqueEvent(2, TimeUnit.MILLISECONDS, THREAD_ONE);
try (BuckEventOrderer<BuckEvent> orderer = new BuckEventOrderer<>(addToSerializedEventsFunction, MAX_SKEW, TimeUnit.MILLISECONDS)) {
orderer.add(second);
orderer.add(third);
orderer.add(fourth);
orderer.add(first);
}
assertThat(serializedEvents, Matchers.contains(first, second, third, fourth));
}
use of com.facebook.buck.event.BuckEvent in project buck by facebook.
the class BuckEventOrdererTest method testPreservesInsertionOrderForSameTimestampWithReverseReorder.
@Test
public void testPreservesInsertionOrderForSameTimestampWithReverseReorder() {
BuckEvent first = createUniqueEvent(0, TimeUnit.MILLISECONDS, THREAD_ONE);
BuckEvent second = createUniqueEvent(0, TimeUnit.MILLISECONDS, THREAD_ONE);
BuckEvent third = createUniqueEvent(0, TimeUnit.MILLISECONDS, THREAD_ONE);
BuckEvent fourth = createUniqueEvent(5, TimeUnit.MILLISECONDS, THREAD_ONE);
try (BuckEventOrderer<BuckEvent> orderer = new BuckEventOrderer<>(addToSerializedEventsFunction, MAX_SKEW, TimeUnit.MILLISECONDS)) {
orderer.add(fourth);
orderer.add(first);
orderer.add(second);
orderer.add(third);
}
assertThat(serializedEvents, Matchers.contains(first, second, third, fourth));
}
Aggregations