Just Enough Items (JEI)

Just Enough Items (JEI)

386M Downloads

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

stepa2 opened this issue ยท 2 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.

commented

This has been automatically marked as stale because it has not had recent activity, and will be closed if no further activity occurs. If this was overlooked, forgotten, or should remain open for any other reason, please reply here to call attention to it and remove the stale status. Thank you for your contributions.

commented

This has been automatically closed because it has not had recent activity. Please feel free to update or reopen it.