autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changing AT_CHECK


From: Akim Demaille
Subject: Changing AT_CHECK
Date: 05 Dec 2000 18:13:05 +0100
User-agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands)

There is obviously a bug in Autotest, as demonstrated by the logs of
Daniele which show some `autoupdate needs GNU sed': these messages
should not have been displayed.  Maybe the trouble he experiences on
his Solaris system would be related to a shell bug triggered by our
suspicious handling of fds.

I tried to track it down, and wasted a few hours trying to understand
where `testsuite' got lost in FD changes.  But I grew tired of all
this, and decided to stop playing with fds.

The result is much clearer than what it used to be (imho), but there
is one functionality which is then changed.  I'm not too much in favor
of restoring this feature: option -n used to disable the redirection
and checking of stdout and stderr.  I practiced Autotest quite a lot,
and my opinion is that this is not needed.  But of course, it's only
mine.  Since I know, Fran├žois, that you use Autotest too, I'd like to
have your opinion too.

For your information, here is the resulting AT_CHECK.  I also think
`0' is a better default for the expected exit status, as opposed to
`ignore'.



# AT_CHECK(COMMANDS, [STATUS = 0], STDOUT, STDERR)
# ------------------------------------------------
# Execute a test by performing given shell COMMANDS.  These commands
# should normally exit with STATUS, while producing expected STDOUT and
# STDERR contents.  The special word `expout' for STDOUT means that file
# `expout' contents has been set to the expected stdout.  The special word
# `experr' for STDERR means that file `experr' contents has been set to
# the expected stderr.
# STATUS is not checked if it is `ignore'.
# STDOUT and STDERR can be the special value `ignore', in which case
# their content is not checked.
m4_define([AT_CHECK],
[$at_traceoff
$at_verbose "$srcdir/AT_LINE: m4_patsubst([$1], [\([\"`$]\)], \\\1)"
echo AT_LINE >at-check-line
$at_traceon
( $1 ) >stdout 2>stderr
at_status=$?
$at_traceoff
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



and here is the protopatch relative to CVS Autoconf.



Index: tests/atgeneral.m4
===================================================================
RCS file: /cvs/autoconf/tests/atgeneral.m4,v
retrieving revision 1.34
diff -u -u -r1.34 atgeneral.m4
--- tests/atgeneral.m4 2000/12/02 00:46:57 1.34
+++ tests/atgeneral.m4 2000/12/05 16:56:06
@@ -113,10 +113,10 @@
 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 @@
   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 @@

 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,45 +432,35 @@
 [$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_ifval([$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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]