fortrangoingonforty/fortsh / 4a12211

Browse files

always wait_for_prompt after Ctrl+C in test runner

Ctrl+C always returns to prompt regardless of the next step type.
Previously only waited when next step needed input (send/send_key),
but Ctrl+C during command substitution needs prompt sync even when
next step is 'wait'. Fixes signals_jobs test 38.

signals_jobs: 39/39 (100%) — all signal and job control tests pass.
Authored by espadonne
SHA
4a12211b6bbd3c281946b84ab2547fb114af3eff
Parents
5783e53
Tree
7b4be6c

1 changed file

StatusFile+-
M tests/interactive/run_tests.py 15 8
tests/interactive/run_tests.pymodified
@@ -381,19 +381,26 @@ class YAMLTestRunner:
381381
             if self._use_marker_sync and key in ('C-c', 'C-z') and not is_last:
382382
                 # Signal keys interrupt/suspend commands — shell needs to
383383
                 # process the signal, reap children, and return to readline.
384
-                # Only wait if more steps follow (next is send/send_key that
385
-                # needs readline to be ready). If this is the last step or
386
-                # near-last, let expect_output find the signal message.
387
-                next_needs_input = (next_step is not None and
388
-                                    ('send' in next_step or 'send_key' in next_step or
389
-                                     'send_line' in next_step))
390
-                if next_needs_input:
384
+                if key == 'C-c':
385
+                    # Ctrl+C always returns to prompt — wait for it, clear buffer
391386
                     try:
392387
                         fortsh.wait_for_prompt(timeout=self.pty_timeout)
393388
                     except pexpect.TIMEOUT:
394389
                         time.sleep(0.5)
390
+                    fortsh.clear_buffer()
395391
                 else:
396
-                    time.sleep(0.5)
392
+                    # Ctrl+Z: only wait if next step needs input, otherwise
393
+                    # let expect_output find the Stopped message
394
+                    next_needs_input = (next_step is not None and
395
+                                        ('send' in next_step or 'send_key' in next_step or
396
+                                         'send_line' in next_step))
397
+                    if next_needs_input:
398
+                        try:
399
+                            fortsh.wait_for_prompt(timeout=self.pty_timeout)
400
+                        except pexpect.TIMEOUT:
401
+                            time.sleep(0.5)
402
+                    else:
403
+                        time.sleep(0.5)
397404
             else:
398405
                 time.sleep(0.02 * ds)
399406
         elif 'send_keys' in step: