* tests/atgeneral.m4 (AT_INIT): Set up FD 5.
(AT_CHECK): Instead of using exec to globally change the FDs of
`testsuite', enclose the body of the test into a
`(..) >stdout 2>stderr'.
In every case, when verbose, display the differences between
expected and oberved (stdout, stderr, exit status).
Let `0' be the default for EXIT-STATUS.
Support EXIT-STATUS == `ignore'.
+2000-12-06 Akim Demaille <akim@epita.fr>
+
+ Stop playing with FDs in Autotest.
+
+ * tests/atgeneral.m4 (AT_INIT): Set up FD 5.
+ (AT_CHECK): Instead of using exec to globally change the FDs of
+ `testsuite', enclose the body of the test into a
+ `(..) >stdout 2>stderr'.
+ In every case, when verbose, display the differences between
+ expected and oberved (stdout, stderr, exit status).
+ Let `0' be the default for EXIT-STATUS.
+ Support EXIT-STATUS == `ignore'.
+
2000-12-06 Akim Demaille <akim@epita.fr>
* tests/tools.at (autoconf: forbidden tokens): Adjust expected
test -f atlocal && . ./atlocal
# -e sets to true
-at_stop_on_error=false;
+at_stop_on_error=false
# Shall we save and check stdout and stderr?
# -n sets to false
-at_check_stds=:;
+at_check_stds=:
# Shall we be verbose?
at_verbose=:
# Shall we keep the debug scripts? Must be `:' when testsuite is
exit 1
fi
+# Setting up the FDs.
+# 5 is stdout conditioned by verbosity.
+if test $at_verbose = echo; then
+ exec 5>&1
+else
+ exec 5>/dev/null
+fi
+
at_failed_list=
at_ignore_count=0
at_test_count=0
for at_test in $at_tests
do
- at_status=0;
+ at_status=0
case $at_test in
dnl Tests inserted here (TESTS).
m4_divert([TAIL])[]dnl
[$at_traceoff
$at_verbose "$srcdir/AT_LINE: m4_patsubst([$1], [\([\"`$]\)], \\\1)"
echo AT_LINE >at-check-line
-$at_check_stds && exec 5>&1 6>&2 1>stdout 2>stderr
$at_traceon
-$1
-m4_ifvaln([$2],
- [at_status=$?
+( $1 ) >stdout 2>stderr
+at_status=$?
$at_traceoff
-if test $at_status != $2; then
- $at_verbose "Exit code was $at_status, expected $2" >&6
-dnl Maybe there was an important message to read before it died.
- $at_verbose = echo && $at_check_stds && cat stderr >&6
-dnl Preserve exit code 77.
- test $at_status = 77 && exit 77
- exit 1
-fi],
- [$at_traceoff])[]dnl
-if $at_check_stds; then
-dnl Restore stdout to fd1 and stderr to fd2.
- exec 1>&5 2>&6
-dnl If not verbose, neutralize the output of diff.
- test $at_verbose = : && exec 1>/dev/null 2>/dev/null
- at_failed=false;
- m4_case([$4],
- ignore, [$at_verbose = echo && cat stderr;:],
- experr, [AT_CLEANUP_FILE([experr])dnl
-$at_diff experr stderr || at_failed=:],
- [], [$at_diff empty stderr || at_failed=:],
- [echo $at_n "m4_patsubst([$4], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stderr || at_failed=:])
- m4_case([$3],
- ignore, [test $at_verbose = echo && cat stdout;:],
- expout, [AT_CLEANUP_FILES([expout])dnl
-$at_diff expout stdout || at_failed=:],
- [], [$at_diff empty stdout || at_failed=:],
- [echo $at_n "m4_patsubst([$3], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stdout || at_failed=:])
- if $at_failed; then
- exit 1
- else
- :
- fi
-fi
+at_continue=:
+dnl Check stderr.
+m4_case([$4],
+ ignore, [cat stderr >&5],
+ experr, [AT_CLEANUP_FILE([experr])dnl
+$at_diff experr stderr >&5 || at_continue='exit 1'],
+ [], [$at_diff empty stderr >&5 || at_continue='exit 1'],
+ [echo $at_n "m4_patsubst([$4], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stderr >&5 || at_continue='exit 1'])
+dnl Check stdout.
+m4_case([$3],
+ ignore, [cat stdout >&5],
+ expout, [AT_CLEANUP_FILES([expout])dnl
+$at_diff expout stdout >&5 || at_continue='exit 1'],
+ [], [$at_diff empty stdout >&5 || at_continue='exit 1'],
+ [echo $at_n "m4_patsubst([$3], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stdout >&5 || at_continue=:])
+dnl Check exit val.
+case $at_status in
+ 77) exit 77;;
+m4_case([$2],
+ [ignore],
+ [ *);;],
+ [ m4_default([$2], [0])) ;;
+ *) $at_verbose "Exit code was $at_status, expected $2" >&2
+ at_continue='exit 1';;])
+esac
+$at_continue
$at_traceon
])# AT_CHECK
test -f atlocal && . ./atlocal
# -e sets to true
-at_stop_on_error=false;
+at_stop_on_error=false
# Shall we save and check stdout and stderr?
# -n sets to false
-at_check_stds=:;
+at_check_stds=:
# Shall we be verbose?
at_verbose=:
# Shall we keep the debug scripts? Must be `:' when testsuite is
exit 1
fi
+# Setting up the FDs.
+# 5 is stdout conditioned by verbosity.
+if test $at_verbose = echo; then
+ exec 5>&1
+else
+ exec 5>/dev/null
+fi
+
at_failed_list=
at_ignore_count=0
at_test_count=0
for at_test in $at_tests
do
- at_status=0;
+ at_status=0
case $at_test in
dnl Tests inserted here (TESTS).
m4_divert([TAIL])[]dnl
[$at_traceoff
$at_verbose "$srcdir/AT_LINE: m4_patsubst([$1], [\([\"`$]\)], \\\1)"
echo AT_LINE >at-check-line
-$at_check_stds && exec 5>&1 6>&2 1>stdout 2>stderr
$at_traceon
-$1
-m4_ifvaln([$2],
- [at_status=$?
+( $1 ) >stdout 2>stderr
+at_status=$?
$at_traceoff
-if test $at_status != $2; then
- $at_verbose "Exit code was $at_status, expected $2" >&6
-dnl Maybe there was an important message to read before it died.
- $at_verbose = echo && $at_check_stds && cat stderr >&6
-dnl Preserve exit code 77.
- test $at_status = 77 && exit 77
- exit 1
-fi],
- [$at_traceoff])[]dnl
-if $at_check_stds; then
-dnl Restore stdout to fd1 and stderr to fd2.
- exec 1>&5 2>&6
-dnl If not verbose, neutralize the output of diff.
- test $at_verbose = : && exec 1>/dev/null 2>/dev/null
- at_failed=false;
- m4_case([$4],
- ignore, [$at_verbose = echo && cat stderr;:],
- experr, [AT_CLEANUP_FILE([experr])dnl
-$at_diff experr stderr || at_failed=:],
- [], [$at_diff empty stderr || at_failed=:],
- [echo $at_n "m4_patsubst([$4], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stderr || at_failed=:])
- m4_case([$3],
- ignore, [test $at_verbose = echo && cat stdout;:],
- expout, [AT_CLEANUP_FILES([expout])dnl
-$at_diff expout stdout || at_failed=:],
- [], [$at_diff empty stdout || at_failed=:],
- [echo $at_n "m4_patsubst([$3], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stdout || at_failed=:])
- if $at_failed; then
- exit 1
- else
- :
- fi
-fi
+at_continue=:
+dnl Check stderr.
+m4_case([$4],
+ ignore, [cat stderr >&5],
+ experr, [AT_CLEANUP_FILE([experr])dnl
+$at_diff experr stderr >&5 || at_continue='exit 1'],
+ [], [$at_diff empty stderr >&5 || at_continue='exit 1'],
+ [echo $at_n "m4_patsubst([$4], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stderr >&5 || at_continue='exit 1'])
+dnl Check stdout.
+m4_case([$3],
+ ignore, [cat stdout >&5],
+ expout, [AT_CLEANUP_FILES([expout])dnl
+$at_diff expout stdout >&5 || at_continue='exit 1'],
+ [], [$at_diff empty stdout >&5 || at_continue='exit 1'],
+ [echo $at_n "m4_patsubst([$3], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stdout >&5 || at_continue=:])
+dnl Check exit val.
+case $at_status in
+ 77) exit 77;;
+m4_case([$2],
+ [ignore],
+ [ *);;],
+ [ m4_default([$2], [0])) ;;
+ *) $at_verbose "Exit code was $at_status, expected $2" >&2
+ at_continue='exit 1';;])
+esac
+$at_continue
$at_traceon
])# AT_CHECK
# Create a header
AT_CHECK([./configure what_to_test=header], 0, ignore)
-AT_CHECK([ls header file command link 2>/dev/null], [], [header
+AT_CHECK([ls header file command link 2>/dev/null], [ignore], [header
])
# Create a file
AT_CHECK([./configure what_to_test=file], 0, ignore)
-AT_CHECK([ls header file command link 2>/dev/null], [], [file
+AT_CHECK([ls header file command link 2>/dev/null], [ignore], [file
])
# Execute a command
AT_CHECK([./configure what_to_test=command], 0, ignore)
-AT_CHECK([ls header file command link 2>/dev/null], [], [command
+AT_CHECK([ls header file command link 2>/dev/null], [ignore], [command
])
# Create a link
AT_CHECK([./configure what_to_test=link], 0, ignore)
-AT_CHECK([ls header file command link 2>/dev/null], [], [link
+AT_CHECK([ls header file command link 2>/dev/null], [ignore], [link
])
AT_CLEANUP(header file link command header.in file.in link.in command.in configure config.status)