From: Ben Pfaff Date: Sat, 18 Mar 2023 18:43:16 +0000 (-0700) Subject: Ensure that interactive output appears without a one-command delay. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a440e2aefd92b7f0f99038bee671ea708d649f8f;p=pspp Ensure that interactive output appears without a one-command delay. When pspp was run in the text-based mode interactively, output for a given command only appeared after the next command was read. This fixes the problem and adds a test. Thanks to the anonymous reporter. Bug #63910. --- diff --git a/src/language/command.c b/src/language/command.c index e67f6ab808..0c77337695 100644 --- a/src/language/command.c +++ b/src/language/command.c @@ -252,13 +252,13 @@ finish: result = lex_end_of_command (lexer); lex_discard_rest_of_command (lexer); + if (nesting_level != SIZE_MAX) + output_close_groups (nesting_level); + if (result != CMD_EOF && result != CMD_FINISH) while (lex_token (lexer) == T_ENDCMD) lex_get (lexer); - if (nesting_level != SIZE_MAX) - output_close_groups (nesting_level); - return result; } diff --git a/tests/automake.mk b/tests/automake.mk index 9d9bc8bcc8..e6782b10fc 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -314,6 +314,7 @@ EXTRA_DIST += \ tests/language/commands/readnames.ods \ tests/language/commands/nhtsa.sav \ tests/language/commands/llz.zsav \ + tests/ui/terminal/squish-pty.py \ tests/utilities/regress.spv CLEANFILES += *.save pspp.* foo* diff --git a/tests/language/commands/define.at b/tests/language/commands/define.at index 2e1a7eebad..d4803246c2 100644 --- a/tests/language/commands/define.at +++ b/tests/language/commands/define.at @@ -1158,7 +1158,7 @@ define.sps:1-3: inside the expansion of `!macro', define.sps:1-3: inside the expansion of `!macro', define.sps:1-3: inside the expansion of `!macro', define.sps:1-3: inside the expansion of `!macro', -define.sps:4.1-4.6: error: DEFINE: Maximum nesting level 50 exceeded. (Use SET MNEST to change the limit.) +define.sps:4.1-4.6: error: Maximum nesting level 50 exceeded. (Use SET MNEST to change the limit.) 4 | !macro. | ^~~~~~" diff --git a/tests/language/commands/split-file.at b/tests/language/commands/split-file.at index a66671278b..ce12db8de9 100644 --- a/tests/language/commands/split-file.at +++ b/tests/language/commands/split-file.at @@ -168,6 +168,7 @@ SHOW SPLIT. AT_CHECK([pspp show.sps -O box=unicode], [0], [dnl SET PRINTBACK=ON. + SHOW SPLIT. Settings diff --git a/tests/output/ascii.at b/tests/output/ascii.at index ce000d65fb..670d311f7a 100644 --- a/tests/output/ascii.at +++ b/tests/output/ascii.at @@ -612,6 +612,7 @@ BEGIN DATA. 3 33 Three END DATA. + REGRESSION /VARIABLES= a diff --git a/tests/ui/terminal/main.at b/tests/ui/terminal/main.at index 29fef65843..e4f4ced3a3 100644 --- a/tests/ui/terminal/main.at +++ b/tests/ui/terminal/main.at @@ -39,7 +39,6 @@ AT_CHECK([pspp main.sps & sleep 1; kill $!; wait $!], [143], [], [ignore]) AT_CLEANUP AT_SETUP([SIGSEGV yields error report]) - # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS @@ -60,7 +59,6 @@ EOF AT_CHECK([sed '/proximate/q' < stderr], [0], [expout]) AT_CLEANUP - dnl This tests for a crash which was observed with --syntax AT_SETUP([argument parsing]) @@ -70,5 +68,27 @@ FINISH. ]) AT_CHECK([pspp --syntax=enhanced main.sps], [0], [ignore]) +AT_CLEANUP +dnl Bug #63910 reported that command output was delayed until the +dnl next command was supplied. This checks for regression against +dnl that bug. +AT_SETUP([interactive output appears immediately]) +dnl We have to use squish-pty to make PSPP think that we're running +dnl interactively. First make sure that squish-pty works at all. +SQUISH_PTY="$PYTHON3 $top_srcdir/tests/ui/terminal/squish-pty.py" +AT_CHECK([$SQUISH_PTY true /dev/null 2>/dev/null || exit 77]) +dnl Then do the real test. The crucial thing to notice here is +dnl that the SHOW output must appear before the prompt for FINISH. +AT_CHECK([echo 'SHOW N. +FINISH.' | $SQUISH_PTY pspp], [0], [stdout]) +AT_CHECK([sed -n 's/ $// +/^PSPP>/,$p' stdout], [0], [dnl +PSPP> SHOW N. + Settings ++-+-------+ +|N|Unknown| ++-+-------+ +PSPP> FINISH. +]) AT_CLEANUP diff --git a/tests/ui/terminal/squish-pty.py b/tests/ui/terminal/squish-pty.py new file mode 100644 index 0000000000..53132cf915 --- /dev/null +++ b/tests/ui/terminal/squish-pty.py @@ -0,0 +1,26 @@ +#! /usr/bin/python3 +import os +import pty +import signal +import sys + +def main(args): + if len(args) < 2: + sys.stderr.write('''\ +usage: squish-pty COMMAND [ARG]... +Squishes both stdin and stdout into a single pseudoterminal and +passes it as stdin and stdout to the specified COMMAND. +''') + return 1 + + status = pty.spawn(args[1:]) + if os.WIFEXITED(status): + return os.WEXITSTATUS(status) + elif os.WIFSIGNALED(status): + signal.raise_signal(os.WTERMSIG(status)) + else: + assert False + +if __name__ == '__main__': + sys.exit(main(sys.argv)) +