autoconf-patches
[Top][All Lists]
Advanced

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

AT Macro to Log a File on Failure


From: Noah Misch
Subject: AT Macro to Log a File on Failure
Date: Wed, 29 Dec 2004 04:57:05 -0800
User-agent: Mutt/1.5.6i

`AT_CHECK_CONFIGURE' uses custom RUN-IF-FAIL commands to log the contents of
`config.log' when `configure' fails.  It seemed to me that this would be useful
as a generic facility, so I rolled one, `AT_CAPTURE_FILE'.  I think it is fairly
straightforward, and I put it to use in `AT_CHECK_CONFIGURE' and `AT_CHECK_AT'.

2004-12-29  Noah Misch  <address@hidden>

        * lib/autotest/general.m4 (AT_CAPTURE_FILE): New macro.
        (AT_SETUP): Clear AT_capture_files.
        (_AT_CHECK): On failure, log each of AT_capture_files.  Fix comment.
        (AT_KEYWORDS): Fix comment typo.
        * tests/autotest.at (AT_CHECK_AT): Use AT_CAPTURE_FILE.
        * tests/local.at (AT_CHECK_CONFIGURE): Use AT_CAPTURE_FILE.
        * doc/autoconf.texi (Writing testsuite.at): Document AT_CAPTURE_FILE.

diff -urp -X dontdiff ac-clean/doc/autoconf.texi 
ac-capture_file/doc/autoconf.texi
--- ac-clean/doc/autoconf.texi  2004-12-23 20:43:15.000000000 -0500
+++ ac-capture_file/doc/autoconf.texi   2004-12-29 06:15:09.621186112 -0500
@@ -15460,6 +15460,14 @@ other words, don't fear registering seve
 test group.
 @end defmac
 
address@hidden AT_CAPTURE_FILE (@var{file})
address@hidden
+If the current test group fails, log the contents of @var{file}.  M4
+expands macros in @var{file}, and the shell expands the result within
+double quotes to craft the name of the file to log.  Several identical
+calls within one test group have no additional effect.
address@hidden defmac
+
 @defmac AT_XFAIL_IF (@var{shell-condition})
 @atindex{XFAIL_IF}
 Determine whether the test is expected to fail because it is a known
diff -urp -X dontdiff ac-clean/lib/autotest/general.m4 
ac-capture_file/lib/autotest/general.m4
--- ac-clean/lib/autotest/general.m4    2004-12-23 20:43:15.000000000 -0500
+++ ac-capture_file/lib/autotest/general.m4     2004-12-29 06:21:25.384917964 
-0500
@@ -1040,6 +1040,7 @@ m4_define([AT_TESTED],
 # The group is testing what DESCRIPTION says.
 m4_define([AT_SETUP],
 [m4_ifdef([AT_keywords], [m4_undefine([AT_keywords])])
+m4_ifdef([AT_capture_files], [m4_undefine([AT_capture_files])])
 m4_define([AT_line], AT_LINE)
 m4_define([AT_xfail], [at_xfail=no])
 m4_define([AT_description], [$1])
@@ -1071,13 +1072,21 @@ m4_case([$1],
       $1 && at_xfail=yes])])])
 
 
-# AT_KEYWORDS(KEYOWRDS)
+# AT_KEYWORDS(KEYWORDS)
 # ---------------------
 # Declare a list of keywords associated to the current test group.
 m4_define([AT_KEYWORDS],
 [m4_append_uniq([AT_keywords], [$1], [ ])])
 
 
+# AT_CAPTURE_FILE(FILE)
+# ---------------------
+# If the current test group does not behave as expected, save the contents of
+# FILE in the test suite log.
+m4_define([AT_CAPTURE_FILE],
+[m4_append_uniq([AT_capture_files], ["$1"], [ ])])
+
+
 # AT_CLEANUP
 # ----------
 # Complete a group of related tests.
@@ -1378,7 +1387,10 @@ m4_case([$2],
       at_failed=:;;])
 esac
 AS_IF($at_failed, [$5
+  m4_ifdef([AT_capture_files],
+    [for file in AT_capture_files
+     do echo "$file:"; sed 's/^/> /' "$file"; done])
   echo 1 > "$at_status_file"
   exit 1], [$6])
 $at_traceon
-])# AT_CHECK_NOESCAPE
+])# _AT_CHECK
diff -urp -X dontdiff ac-clean/tests/autotest.at 
ac-capture_file/tests/autotest.at
--- ac-clean/tests/autotest.at  2004-12-20 04:55:01.000000000 -0500
+++ ac-capture_file/tests/autotest.at   2004-12-29 06:00:04.612648790 -0500
@@ -30,6 +30,7 @@ m4_define([AT_CHECK_AT],
 [
 AT_SETUP([$1])
 AT_KEYWORDS([autotest])
+AT_CAPTURE_FILE([micro-suite.log])
 AT_XFAIL_IF([$3])
 
 AT_DATA([package.m4],[[
diff -urp -X dontdiff ac-clean/tests/local.at ac-capture_file/tests/local.at
--- ac-clean/tests/local.at     2004-12-12 14:43:29.000000000 -0500
+++ ac-capture_file/tests/local.at      2004-12-24 22:26:59.000000000 -0500
@@ -258,11 +258,10 @@ m4_define([AT_CHECK_AUTOHEADER],
 # `abs_top_srcdir' is needed so that `./configure' finds install-sh.
 # Using --srcdir is more expensive.
 m4_define([AT_CHECK_CONFIGURE],
-[AT_CHECK([top_srcdir=$abs_top_srcdir ./configure $1],
+[AT_CAPTURE_FILE([config.log])[]dnl
+ AT_CHECK([top_srcdir=$abs_top_srcdir ./configure $1],
          [$2],
-         m4_default([$3], [ignore]), [$4],
-         [{ echo "$srcdir/AT_LINE: config.log"; sed 's/^/> /' config.log; } 
>>$at_group_log ])
-])
+         m4_default([$3], [ignore]), [$4])])
 
 
 # AT_CHECK_ENV




reply via email to

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