From: Akim Demaille Date: Thu, 23 Nov 2000 09:52:35 +0000 (+0000) Subject: * tests/atgeneral.m4 (AT_CLEAN_FILE_IFELSE, AT_CLEANUP_FILE) X-Git-Tag: autoconf-2.50~397 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0280c4a5352e6d59fe273df3814ee52ef23a39e1;p=thirdparty%2Fautoconf.git * 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. --- diff --git a/ChangeLog b/ChangeLog index fbe8bab72..b3d679b58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2000-11-23 Akim Demaille + + * 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 * tests/atgeneral.m4 (AT_INIT) : Be a :/echo variable. diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4 index f4e3ccf41..ce6e48d21 100644 --- a/lib/autotest/general.m4 +++ b/lib/autotest/general.m4 @@ -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=:]) diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4 index 6d324be1e..65073d5ad 100644 --- a/lib/m4sugar/m4sugar.m4 +++ b/lib/m4sugar/m4sugar.m4 @@ -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) diff --git a/m4sugar.m4 b/m4sugar.m4 index 6d324be1e..65073d5ad 100644 --- a/m4sugar.m4 +++ b/m4sugar.m4 @@ -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) diff --git a/tests/atgeneral.m4 b/tests/atgeneral.m4 index f4e3ccf41..ce6e48d21 100644 --- a/tests/atgeneral.m4 +++ b/tests/atgeneral.m4 @@ -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=:]) diff --git a/tests/atspecific.m4 b/tests/atspecific.m4 index f7645d23d..8e180ca5a 100644 --- a/tests/atspecific.m4 +++ b/tests/atspecific.m4 @@ -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 diff --git a/tests/base.at b/tests/base.at index baf51d7b6..cdfc18d6a 100644 --- a/tests/base.at +++ b/tests/base.at @@ -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) diff --git a/tests/m4sh.at b/tests/m4sh.at index 732bfb1c8..1d4ced6eb 100644 --- a/tests/m4sh.at +++ b/tests/m4sh.at @@ -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) diff --git a/tests/semantics.at b/tests/semantics.at index 946cd308b..0d55023e8 100644 --- a/tests/semantics.at +++ b/tests/semantics.at @@ -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 diff --git a/tests/tools.at b/tests/tools.at index d4bdc3c11..da3f0c2e4 100644 --- a/tests/tools.at +++ b/tests/tools.at @@ -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 diff --git a/tests/torture.at b/tests/torture.at index 4f2164a8c..35bb43b5a 100644 --- a/tests/torture.at +++ b/tests/torture.at @@ -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,