{
struct lex_reader *reader;
- reader = (!strcmp (file_name, "-") && isatty (STDIN_FILENO)
+ bool interactive;
+ if (!strcmp (file_name, "-"))
+ {
+ /* This allows the testsuite to simulate interactive behavior by setting
+ PSPP_INTERACTIVE=1 in the environment. */
+ const char *env = getenv ("PSPP_INTERACTIVE");
+ interactive = env ? strcmp (env, "0") : isatty (STDIN_FILENO);
+ }
+ else
+ interactive = false;
+
+ reader = (interactive
? terminal_reader_create ()
: lex_reader_for_file (file_name, encoding, syntax_mode,
LEX_ERROR_CONTINUE));
# Avoid complaints if the system doesn't have a configured paper size.
export PAPERSIZE=a4
+
+# Make PSPP ignore whether stdin is a tty.
+export PSPP_INTERACTIVE=0
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*
AT_CLEANUP
AT_SETUP([journal enabled by default interactively])
-AT_SKIP_IF([test "$SQUISH_PTY" = no])
AT_CHECK([echo 'data list notable /x y 1-2.
-finish.' | XDG_STATE_HOME=$PWD $SQUISH_PTY pspp], [0], [ignore])
+finish.' | XDG_STATE_HOME=$PWD PSPP_INTERACTIVE=1 pspp], [0], [ignore])
AT_CHECK([sed 's/New session at .*/New session./' pspp/pspp.jnl], [0], [dnl
* New session.
data list notable /x y 1-2.
PATH=$wrapper_dir:$PATH
fi
])
-
-m4_divert_text([PREPARE_TESTS], [dnl
-dnl ptys are pretty system-dependent and it's hard to test them
-dnl everywhere. For example, on Mac OS the SHOW N and FINISH command
-dnl text doesn't appear in the output. So we'll just skip them
-dnl other than on the OS we know best.
-AS_CASE([$host],
- [*-linux*],
- [dnl Make sure that squish-pty works.
- SQUISH_PTY="$PYTHON3 $abs_top_srcdir/tests/ui/terminal/squish-pty.py"
- if $SQUISH_PTY true </dev/null >/dev/null 2>/dev/null; then
- :
- else
- SQUISH_PTY=no
- fi],
- [SQUISH_PTY=no])
-])
dnl next command was supplied. This checks for regression against
dnl that bug.
AT_SETUP([interactive output appears immediately])
-AT_SKIP_IF([test "$SQUISH_PTY" = no])
dnl The crucial thing to notice below is that the SHOW output
dnl must appear before the prompt for FINISH.
AT_CHECK([echo 'SHOW N.
-FINISH.' | $SQUISH_PTY pspp], [0], [stdout])
+FINISH.' | PSPP_INTERACTIVE=1 pspp], [0], [stdout])
AT_CHECK([sed -n 's/\r$//
/^PSPP>/,$p' stdout], [0], [dnl
PSPP> SHOW N.
+++ /dev/null
-#! /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))
-