File tree Expand file tree Collapse file tree
src/test/java/io/github/easy4j/codex/cli Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323import static org .junit .jupiter .api .Assertions .assertNotNull ;
2424import static org .junit .jupiter .api .Assertions .assertTrue ;
2525
26+ import java .util .concurrent .TimeUnit ;
27+
2628/**
2729 * Unit tests for {@link CodexCliExecutor}.
2830 *
@@ -158,6 +160,22 @@ void shouldReportFailureFromProbeWhenExecutableMissing() {
158160 assertFalse (executor .probe ());
159161 }
160162
163+ @ Test
164+ void shouldUseDedicatedProbeTimeoutWithoutChangingNormalTimeout () {
165+ CodexClientConfig config = configFor ("/bin/sh -c \" sleep 4; exit 0\" " );
166+ config .setLocalProbeTimeoutSeconds (1 );
167+ config .setLocalTimeoutSeconds (8 );
168+ CodexCliExecutor executor = new CodexCliExecutor (config );
169+
170+ long started = System .nanoTime ();
171+ boolean available = executor .probe ();
172+ long elapsedMs = TimeUnit .NANOSECONDS .toMillis (System .nanoTime () - started );
173+
174+ assertFalse (available , "probe must time out using localProbeTimeoutSeconds" );
175+ assertTrue (elapsedMs < 3_000 ,
176+ "probe must not wait for the normal localTimeoutSeconds window; elapsed=" + elapsedMs );
177+ }
178+
161179 @ Test
162180 void shouldTimeoutOnHangingProcess () {
163181 // Use a short timeout and a command that sleeps for a long time.
You can’t perform that action at this time.
0 commit comments