Summary
Several test files use Thread.sleep with very short durations (10-50ms) to wait for async command execution. These are the most likely to flake on CI since the sleep may not be long enough for slower CI runners.
Proposed fix
Replace Thread.sleep + assertion with CommandExecutionListener + CountDownLatch pattern, as demonstrated in CommandExecutionListenerTest.java and the fix for AeshCommandInvocationServiceTest (commit 897d0b95).
Pattern:
CountDownLatch latch = new CountDownLatch(1);
// Register via SettingsBuilder:
.commandExecutionListener((line, result, durationMs) -> latch.countDown())
connection.read("command" + Config.getLineSeparator());
assertTrue(latch.await(5, TimeUnit.SECONDS));
// Assert output...
Files to convert (priority order by sleep duration)
| File |
Sleep(ms) |
Occurrences |
AeshCommandInputTest.java |
10ms |
3 |
AeshCommandDynamicTest.java |
10ms |
1 |
AeshScriptTest.java |
20ms |
1 |
AeshCommandOptionValidatorTest.java |
20ms |
1 |
AeshCommandNotFoundHandlerTest.java |
50ms |
1 |
AeshConverterInvocationProviderTest.java |
50ms |
1 |
AeshCommandPasteTest.java |
50ms |
1 |
ConsoleRedirectionTest.java |
50ms |
6 |
ExportCommandTest.java |
50ms |
1 |
AeshCommandRegistryTest.java |
50ms |
3 |
Notes
- Not all
Thread.sleep calls wait for command execution — some wait for completion rendering or other async events. TestConnection.waitForOutputContaining() may be more appropriate for output-based waits.
- Each test should be verified individually after conversion.
Summary
Several test files use
Thread.sleepwith very short durations (10-50ms) to wait for async command execution. These are the most likely to flake on CI since the sleep may not be long enough for slower CI runners.Proposed fix
Replace
Thread.sleep+ assertion withCommandExecutionListener+CountDownLatchpattern, as demonstrated inCommandExecutionListenerTest.javaand the fix forAeshCommandInvocationServiceTest(commit 897d0b95).Pattern:
Files to convert (priority order by sleep duration)
AeshCommandInputTest.javaAeshCommandDynamicTest.javaAeshScriptTest.javaAeshCommandOptionValidatorTest.javaAeshCommandNotFoundHandlerTest.javaAeshConverterInvocationProviderTest.javaAeshCommandPasteTest.javaConsoleRedirectionTest.javaExportCommandTest.javaAeshCommandRegistryTest.javaNotes
Thread.sleepcalls wait for command execution — some wait for completion rendering or other async events.TestConnection.waitForOutputContaining()may be more appropriate for output-based waits.