]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* tests/atgeneral.m4 (AT_CLEAN_FILE_IFELSE, AT_CLEANUP_FILE)
authorAkim Demaille <akim@epita.fr>
Thu, 23 Nov 2000 09:52:35 +0000 (09:52 +0000)
committerAkim Demaille <akim@epita.fr>
Thu, 23 Nov 2000 09:52:35 +0000 (09:52 +0000)
(AT_CLEANUP_FILES): New macros.
(AT_SETUP, AT_CHECK, AT_CLEANUP): Use them.
(AT_CHECK): Fix a use of at_verbose.
* tests/atspecific.m4 (AT_CHECK_AUTOCONF, AT_CHECK_AUTOHEADER)
(AT_CHECK_CONFIGURE): New macros.

ChangeLog
lib/autotest/general.m4
lib/m4sugar/m4sugar.m4
m4sugar.m4
tests/atgeneral.m4
tests/atspecific.m4
tests/base.at
tests/m4sh.at
tests/semantics.at
tests/tools.at
tests/torture.at

index fbe8bab72e68eaf00bfd54b1e89a4bcde3a6d11e..b3d679b58c986cccc7c142f936160eeacb0e5357 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2000-11-23  Akim Demaille  <akim@epita.fr>
+
+       * tests/atgeneral.m4 (AT_CLEAN_FILE_IFELSE, AT_CLEANUP_FILE)
+       (AT_CLEANUP_FILES): New macros.
+       (AT_SETUP, AT_CHECK, AT_CLEANUP): Use them.
+       (AT_CHECK): Fix a use of at_verbose.
+       * tests/atspecific.m4 (AT_CHECK_AUTOCONF, AT_CHECK_AUTOHEADER)
+       (AT_CHECK_CONFIGURE): New macros.
+
 2000-11-23  Akim Demaille  <akim@epita.fr>
 
        * tests/atgeneral.m4 (AT_INIT) <at_verbose>: Be a :/echo variable.
index f4e3ccf4102188232b1aa95fff33051a87779e31..ce6e48d2160cbc2cf8570dc7c94a28a581b4c7b5 100644 (file)
@@ -248,9 +248,7 @@ m4_wrap([m4_divert_text(0,
 # The group is testing what DESCRIPTION says.
 AT_DEFINE([AT_SETUP],
 [AT_DEFINE([AT_ordinal], m4_eval(AT_ordinal + 1))
-m4_pushdef([AT_data_files], )
-m4_pushdef([AT_data_expout], )
-m4_pushdef([AT_data_experr], )
+m4_pushdef([AT_data_files], [stdout stderr ])
 m4_divert_pop()dnl
   AT_ordinal )
 dnl Here will be inserted the `rm' corresponding to AT_CLEANUP.
@@ -268,25 +266,48 @@ m4_divert(2)[]dnl
 ])
 
 
+# AT_CLEANUP_FILE_IFELSE(FILE, IF-REGISTERED, IF-NOT-REGISTERED)
+# --------------------------------------------------------------
+AT_DEFINE([AT_CLEANUP_FILE_IFELSE],
+[ifelse(m4_regexp(AT_data_files, m4_patsubst([ $1 ], [\([\[\]*.]\)], [\\\1])),
+        -1,
+        [$3], [$2])])
+
+
+# AT_CLEANUP_FILE(FILE)
+# ---------------------
+# Register FILE for AT_CLEANUP.
+AT_DEFINE([AT_CLEANUP_FILE],
+[AT_CLEANUP_FILE_IFELSE([$1], [],
+                        [m4_append([AT_data_files], [$1 ])])])
+
+
+# AT_CLEANUP_FILES(FILES)
+# -----------------------
+# Declare a list of FILES to clean.
+AT_DEFINE([AT_CLEANUP_FILES],
+[m4_foreach([AT_File], m4_quote(m4_patsubst([$1], [  *], [,])),
+            [AT_CLEANUP_FILE(AT_File)])])
+
+
 # AT_CLEANUP(FILES)
 # -----------------
 # Complete a group of related tests, recursively remove those FILES
 # created within the test.  There is no need to list stdout, stderr,
 # nor files created with AT_DATA.
 AT_DEFINE([AT_CLEANUP],
-[      $at_traceoff
+[AT_CLEANUP_FILES([$1])dnl
+      $at_traceoff
     )
     at_status=$?
     at_test_count=`expr 1 + $at_test_count`
     if $at_stop_on_error && test -n "$at_failed_list"; then :; else
-      rm ifelse([AT_data_files$1], , [-f], [-rf[]AT_data_files[]ifelse($1, , , [ $1])]) stdout stderr[]AT_data_expout[]AT_data_experr
+      rm -rf AT_data_files
     fi
     ;;
 m4_divert(1)[]dnl
-    rm ifelse([AT_data_files$1], , [-f], [-rf[]AT_data_files[]ifelse($1, , , [ $1])]) stdout stderr[]AT_data_expout[]AT_data_experr
+    rm -rf AT_data_files
 m4_undivert(2)[]dnl
-m4_popdef([AT_data_experr])dnl
-m4_popdef([AT_data_expout])dnl
 m4_popdef([AT_data_files])dnl
 m4_divert_push([KILL])dnl
 ])# AT_CLEANUP
@@ -299,7 +320,7 @@ m4_divert_push([KILL])dnl
 # This macro is not robust to active symbols in CONTENTS *on purpose*.
 # If you don't want CONTENT to be evaluated, quote it twice.
 AT_DEFINE([AT_DATA],
-[AT_DEFINE([AT_data_files], AT_data_files[ ]$1)
+[AT_CLEANUP_FILES([$1])dnl
 cat >$1 <<'_ATEOF'
 $2[]_ATEOF
 ])
@@ -339,17 +360,17 @@ 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 = echo && exec 1>/dev/null 2>/dev/null
+  test $at_verbose = : && exec 1>/dev/null 2>/dev/null
   at_failed=false;
   m4_case([$4],
           ignore, [$at_verbose = echo && cat stderr;:],
-          experr, [AT_DEFINE([AT_data_experr], [ experr])dnl
+          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_DEFINE([AT_data_expout], [ expout])dnl
+          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=:])
index 6d324be1e73905c4b47c6c277f2f3a9eae8f819b..65073d5ad41211896e2c4a9ec41bc69ca95ac894 100644 (file)
@@ -1323,7 +1323,7 @@ m4_define([m4_strip],
 #    => active
 m4_define([m4_append],
 [m4_define([$1],
-ifdef([$1], [m4_defn([$1])])[$2])])
+           ifdef([$1], [m4_defn([$1])])[$2])])
 
 
 # m4_list_append(MACRO-NAME, STRING)
@@ -1331,7 +1331,7 @@ ifdef([$1], [m4_defn([$1])])[$2])])
 # Same as `m4_append', but each element is separated by `, '.
 m4_define([m4_list_append],
 [m4_define([$1],
-ifdef([$1], [m4_defn([$1]), ])[$2])])
+           ifdef([$1], [m4_defn([$1]), ])[$2])])
 
 
 # m4_foreach_quoted(VARIABLE, LIST, EXPRESSION)
index 6d324be1e73905c4b47c6c277f2f3a9eae8f819b..65073d5ad41211896e2c4a9ec41bc69ca95ac894 100644 (file)
@@ -1323,7 +1323,7 @@ m4_define([m4_strip],
 #    => active
 m4_define([m4_append],
 [m4_define([$1],
-ifdef([$1], [m4_defn([$1])])[$2])])
+           ifdef([$1], [m4_defn([$1])])[$2])])
 
 
 # m4_list_append(MACRO-NAME, STRING)
@@ -1331,7 +1331,7 @@ ifdef([$1], [m4_defn([$1])])[$2])])
 # Same as `m4_append', but each element is separated by `, '.
 m4_define([m4_list_append],
 [m4_define([$1],
-ifdef([$1], [m4_defn([$1]), ])[$2])])
+           ifdef([$1], [m4_defn([$1]), ])[$2])])
 
 
 # m4_foreach_quoted(VARIABLE, LIST, EXPRESSION)
index f4e3ccf4102188232b1aa95fff33051a87779e31..ce6e48d2160cbc2cf8570dc7c94a28a581b4c7b5 100644 (file)
@@ -248,9 +248,7 @@ m4_wrap([m4_divert_text(0,
 # The group is testing what DESCRIPTION says.
 AT_DEFINE([AT_SETUP],
 [AT_DEFINE([AT_ordinal], m4_eval(AT_ordinal + 1))
-m4_pushdef([AT_data_files], )
-m4_pushdef([AT_data_expout], )
-m4_pushdef([AT_data_experr], )
+m4_pushdef([AT_data_files], [stdout stderr ])
 m4_divert_pop()dnl
   AT_ordinal )
 dnl Here will be inserted the `rm' corresponding to AT_CLEANUP.
@@ -268,25 +266,48 @@ m4_divert(2)[]dnl
 ])
 
 
+# AT_CLEANUP_FILE_IFELSE(FILE, IF-REGISTERED, IF-NOT-REGISTERED)
+# --------------------------------------------------------------
+AT_DEFINE([AT_CLEANUP_FILE_IFELSE],
+[ifelse(m4_regexp(AT_data_files, m4_patsubst([ $1 ], [\([\[\]*.]\)], [\\\1])),
+        -1,
+        [$3], [$2])])
+
+
+# AT_CLEANUP_FILE(FILE)
+# ---------------------
+# Register FILE for AT_CLEANUP.
+AT_DEFINE([AT_CLEANUP_FILE],
+[AT_CLEANUP_FILE_IFELSE([$1], [],
+                        [m4_append([AT_data_files], [$1 ])])])
+
+
+# AT_CLEANUP_FILES(FILES)
+# -----------------------
+# Declare a list of FILES to clean.
+AT_DEFINE([AT_CLEANUP_FILES],
+[m4_foreach([AT_File], m4_quote(m4_patsubst([$1], [  *], [,])),
+            [AT_CLEANUP_FILE(AT_File)])])
+
+
 # AT_CLEANUP(FILES)
 # -----------------
 # Complete a group of related tests, recursively remove those FILES
 # created within the test.  There is no need to list stdout, stderr,
 # nor files created with AT_DATA.
 AT_DEFINE([AT_CLEANUP],
-[      $at_traceoff
+[AT_CLEANUP_FILES([$1])dnl
+      $at_traceoff
     )
     at_status=$?
     at_test_count=`expr 1 + $at_test_count`
     if $at_stop_on_error && test -n "$at_failed_list"; then :; else
-      rm ifelse([AT_data_files$1], , [-f], [-rf[]AT_data_files[]ifelse($1, , , [ $1])]) stdout stderr[]AT_data_expout[]AT_data_experr
+      rm -rf AT_data_files
     fi
     ;;
 m4_divert(1)[]dnl
-    rm ifelse([AT_data_files$1], , [-f], [-rf[]AT_data_files[]ifelse($1, , , [ $1])]) stdout stderr[]AT_data_expout[]AT_data_experr
+    rm -rf AT_data_files
 m4_undivert(2)[]dnl
-m4_popdef([AT_data_experr])dnl
-m4_popdef([AT_data_expout])dnl
 m4_popdef([AT_data_files])dnl
 m4_divert_push([KILL])dnl
 ])# AT_CLEANUP
@@ -299,7 +320,7 @@ m4_divert_push([KILL])dnl
 # This macro is not robust to active symbols in CONTENTS *on purpose*.
 # If you don't want CONTENT to be evaluated, quote it twice.
 AT_DEFINE([AT_DATA],
-[AT_DEFINE([AT_data_files], AT_data_files[ ]$1)
+[AT_CLEANUP_FILES([$1])dnl
 cat >$1 <<'_ATEOF'
 $2[]_ATEOF
 ])
@@ -339,17 +360,17 @@ 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 = echo && exec 1>/dev/null 2>/dev/null
+  test $at_verbose = : && exec 1>/dev/null 2>/dev/null
   at_failed=false;
   m4_case([$4],
           ignore, [$at_verbose = echo && cat stderr;:],
-          experr, [AT_DEFINE([AT_data_experr], [ experr])dnl
+          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_DEFINE([AT_data_expout], [ expout])dnl
+          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=:])
index f7645d23dc849a2a87595c059bda32e1a5c7c721..8e180ca5af28ebc9ebf744e8097e2377f3f78a98 100644 (file)
@@ -25,6 +25,30 @@ include(atgeneral.m4)m4_divert(-1)
 ## ---------------------------------------- ##
 
 
+# AT_CHECK_AUTOCONF
+# -----------------
+AT_DEFINE([AT_CHECK_AUTOCONF],
+[AT_CLEANUP_FILES(configure)dnl
+AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])])
+
+
+# AT_CHECK_AUTOHEADER
+# -------------------
+AT_DEFINE([AT_CHECK_AUTOHEADER],
+[AT_CLEANUP_FILES(config.hin)dnl
+AT_CHECK([autoheader --autoconf-dir .. -l $at_srcdir], 0, [], [])])
+
+
+# AT_CHECK_CONFIGURE
+# -------------------
+AT_DEFINE([AT_CHECK_CONFIGURE],
+[AT_CLEANUP_FILE_IFELSE([config.hin],
+                        [AT_CLEANUP_FILE(config.h)])dnl
+AT_CLEANUP_FILES(config.log config.status config.cache)dnl
+AT_CHECK([top_srcdir=$top_srcdir ./configure], 0, ignore, [])
+test $at_verbose = echo && echo "--- config.log" && cat config.log])
+
+
 # _AT_CHECK_AC_MACRO(AC-BODY, PRE-TESTS)
 # --------------------------------------
 # Create a minimalist configure.in running the macro named
@@ -34,6 +58,7 @@ include(atgeneral.m4)m4_divert(-1)
 # `config.guess' etc.).
 AT_DEFINE([_AT_CHECK_AC_MACRO],
 [dnl Produce the configure.in
+AT_CLEANUP_FILES(env-after state*)dnl
 AT_DATA([configure.in],
 [AC_INIT
 AC_CONFIG_AUX_DIR($top_srcdir)
@@ -44,11 +69,9 @@ AC_STATE_SAVE(after)
 AC_OUTPUT
 ])
 $2
-rm -f state*
-AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
-AT_CHECK([autoheader --autoconf-dir .. -l $at_srcdir], 0, [], [])
-AT_CHECK([top_srcdir=$top_srcdir ./configure], 0, ignore, [])
-test $at_verbose = echo && echo "--- config.log" && cat config.log
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
 
 dnl Some tests might exit prematurely when they find a problem, in
 dnl which case `env-after' is probably missing.  Don't check it then.
@@ -58,7 +81,6 @@ if test -f state-env.after; then
   cp -f state-ls.before expout
   AT_CHECK([cat state-ls.after], 0, expout)
 fi
-rm -f state*
 ])# _AT_CHECK_AC_MACRO
 
 
@@ -74,7 +96,7 @@ AT_DEFINE([AT_CHECK_MACRO],
 
 _AT_CHECK_AC_MACRO([ifelse([$2],,[$1], [$2])])
 $3
-AT_CLEANUP(configure config.status config.log config.cache config.hin config.h env-after)dnl
+AT_CLEANUP()dnl
 ])# AT_CHECK_MACRO
 
 
@@ -93,7 +115,7 @@ _AT_CHECK_AC_MACRO([$1],
           [], [autoupdate: `configure.in' is updated
 ])])
 
-AT_CLEANUP(configure config.status config.log config.cache config.hin config.h env-after)dnl
+AT_CLEANUP()dnl
 ])# AT_CHECK_UPDATE
 
 
index baf51d7b66535fbdaea8569ecc4b2b0e73a373f2..cdfc18d6a00c9e9c0fd4168185622d60e755c788 100644 (file)
@@ -43,7 +43,7 @@ test -z "$test1" &&
 AS_EXIT(0)
 ]])
 
-AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
+AT_CHECK_AUTOCONF
 AT_CHECK([./configure], 0)
 
 AT_CLEANUP(configure)
index 732bfb1c837cfd1c5bf1e9c9ab9069a5484b2989..1d4ced6ebc172951c2426768bd885c7373ad2d6a 100644 (file)
@@ -49,7 +49,7 @@ AS_DIRNAME_TEST([../../2//3/],        [../../2])
 AS_EXIT(0)
 ]])
 
-AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
+AT_CHECK_AUTOCONF
 AT_CHECK([./configure], 0)
 
 AT_CLEANUP(configure)
@@ -79,7 +79,7 @@ test -d a/b/c/d/e/f ||
 AS_EXIT(0)
 ]])
 
-AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
+AT_CHECK_AUTOCONF
 AT_CHECK([./configure], 0)
 
 AT_CLEANUP(configure 1 a)
@@ -108,7 +108,7 @@ case without in
 esac
 ]])
 
-AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
+AT_CHECK_AUTOCONF
 AT_CHECK([./configure], 0)
 
 AT_CLEANUP(configure)
index 946cd308b5dca83fae28dbf73da0c7ded7305e00..0d55023e8176c13fb554bcb416f9363640021f6e 100644 (file)
@@ -272,10 +272,10 @@ $fail &&
 AS_EXIT(0)
 ]])
 
-AT_CHECK([../autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
-AT_CHECK([./configure], 0, ignore)
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
 
-AT_CLEANUP(path config.log config.cache configure)
+AT_CLEANUP(path)
 
 
 # ------------------------------ #
@@ -312,10 +312,10 @@ $fail &&
 AS_EXIT(0)
 ]])
 
-AT_CHECK([../autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
-AT_CHECK([./configure], 0, ignore)
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
 
-AT_CLEANUP(path config.log config.cache configure)
+AT_CLEANUP(path)
 
 
 
@@ -369,7 +369,7 @@ AT_CHECK_DEFINES(
 #define HAVE_STDIO_H 1
 ])
 
-AT_CLEANUP(configure config.status config.log config.cache config.hin config.h env-after)dnl
+AT_CLEANUP()dnl
 
 
 # Non-strict preprocessors work if they produce no warnings.
@@ -399,4 +399,4 @@ AT_CHECK_DEFINES(
 #define HAVE_STDIO_H 1
 ])
 
-AT_CLEANUP(configure config.status config.log config.cache config.hin config.h env-after)dnl
+AT_CLEANUP()dnl
index d4bdc3c11d1c3ce8f608c49840d39f0e8a934a2f..da3f0c2e45090096e4f622deb1153c91f9c8abaa 100644 (file)
@@ -211,7 +211,7 @@ AT_CHECK([autoupdate --autoconf-dir $top_srcdir], 0, [],
          [autoupdate: `configure.in' is updated
 ])
 AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0)
-AT_CHECK([./configure], 0, ignore)
+AT_CHECK_CONFIGURE
 AT_CHECK([cat src1], 0, [dst1
 ])
 AT_CHECK([cat src2], 0, [dst2
index 4f2164a8c466066db225a287c0b334f99df63c5a..35bb43b5a51b3f35df41f6498e8221e060bccb2c 100644 (file)
@@ -33,7 +33,7 @@ esac
 AC_OUTPUT
 ]])
 
-AT_CHECK([../autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
+AT_CHECK_AUTOCONF
 
 # Create a header
 AT_CHECK([./configure what_to_test=header], 0, ignore)
@@ -71,7 +71,7 @@ AC_CONFIG_FILES([nonexistent])
 AC_OUTPUT
 ]])
 
-AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
+AT_CHECK_AUTOCONF
 AT_CHECK([./configure], 1, ignore,
 [[config.status: error: cannot find input file `nonexistent.in'
 ]])
@@ -101,7 +101,7 @@ echo "result=$one$enable_two$with_three"
 AC_OUTPUT
 ]])
 
-AT_CHECK([../autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
+AT_CHECK_AUTOCONF
 
 AT_CHECK([./configure one=one --enable-two=two --with-three=three |
           sed -n -e 's/^result=//p'], 0,
@@ -170,7 +170,7 @@ AT_DATA(config.hin,
 ]])
 
 AT_CHECK([../autoconf --autoconf-dir .. -l $at_srcdir], 0)
-AT_CHECK([./configure], 0, ignore)
+AT_CHECK_CONFIGURE
 
 AT_DATA(expout,
 [[/* config.h.  Generated automatically by configure.  */
@@ -261,9 +261,9 @@ m4_for(AT_Count, 1, 100, 1,
 AC_OUTPUT
 ])
 
-AT_CHECK([../autoconf --autoconf-dir .. -l $at_srcdir], 0, [], [])
-AT_CHECK([../autoheader --autoconf-dir .. -l $at_srcdir], 0, [], [])
-AT_CHECK([./configure], 0, ignore)
+AT_CHECK_AUTOCONF
+AT_CHECK_AUTOHEADER
+AT_CHECK_CONFIGURE
 
 # Checking that AC_DEFINE worked properly.
 AT_DATA(expout,