]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Stop playing with FDs in Autotest.
authorAkim Demaille <akim@epita.fr>
Wed, 6 Dec 2000 16:29:50 +0000 (16:29 +0000)
committerAkim Demaille <akim@epita.fr>
Wed, 6 Dec 2000 16:29:50 +0000 (16:29 +0000)
* 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'.

ChangeLog
lib/autotest/general.m4
tests/atgeneral.m4
tests/torture.at

index 086636ad8e7ed623a4aeea3d3ab543c553844e59..0ff4e7b01a85ce2174d0a33d0f30168ccc85e288 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+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
index e95a68342065d8af89a6af4ea383e84be7ccf176..d11bd598625cda4f28c00524d7b8828bd14be5d6 100644 (file)
@@ -113,10 +113,10 @@ fi
 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
@@ -214,6 +214,14 @@ else
   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
@@ -221,7 +229,7 @@ m4_divert([TESTS])dnl
 
 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
@@ -424,44 +432,35 @@ m4_define([AT_CHECK],
 [$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
index e95a68342065d8af89a6af4ea383e84be7ccf176..d11bd598625cda4f28c00524d7b8828bd14be5d6 100644 (file)
@@ -113,10 +113,10 @@ fi
 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
@@ -214,6 +214,14 @@ else
   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
@@ -221,7 +229,7 @@ m4_divert([TESTS])dnl
 
 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
@@ -424,44 +432,35 @@ m4_define([AT_CHECK],
 [$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
index 8b1f4a27178d166eb96b2c61e156cdf7c5658db2..49de5947efca6f6a5273aeb8d81c7edd61881d61 100644 (file)
@@ -33,22 +33,22 @@ AT_CHECK_AUTOCONF
 
 # 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)