Just Enough Items (JEI)

Just Enough Items (JEI)

307M Downloads

[Bug]: `DeduplicatingRunnerTest.testDeduplicatedRuns` fails on my computer, probably because test implementation is wrong

stepa2 opened this issue ยท 0 comments

commented

Other

@Test
public void testDeduplicatedRuns() throws InterruptedException {
AtomicInteger runs = new AtomicInteger();
Runnable testRunnable = runs::getAndIncrement;
Duration delay = Duration.ofMillis(10);
DeduplicatingRunner deduplicatingRunner = new DeduplicatingRunner(testRunnable, delay, "test");
for (int i = 0; i < 10; i++) {
deduplicatingRunner.run();
}
Assertions.assertEquals(0, runs.get());
Thread.sleep(2 * delay.toMillis());
Assertions.assertEquals(1, runs.get());
}

I guess it happens because on my computer, due to lags when I run :Common:test Gradle task, Thread.sleep ends faster than deduplicatingRunner's actions.
As a hotfix, I increased sleep delay to 5 * delay.toMillis().

To correctly fix it one should not use Thread.sleep at all, or, given enough lags, it will break again.
I think DeduplicatingRunnerTest.testSpacedOutRuns can have the same problem too.