* tests/statesave.m4: New file.
* tests/Makefile.am (EXTRA_DIST): Distribute it.
* tests/local.at (AT_CONFIGURE_AC): Reuse file, rather than
repeating inline definition of AC_STATE_SAVE.
(AT_CHECK_ENV): Factor code...
(_AT_CHECK_ENV): ...into shell function.
* tests/m4sh.at (AT_DATA_LINENO): Avoid churn in testsuite.
Signed-off-by: Eric Blake <ebb9@byu.net>
2009-04-06 Eric Blake <ebb9@byu.net>
+ Reduce testsuite size.
+ * tests/statesave.m4: New file.
+ * tests/Makefile.am (EXTRA_DIST): Distribute it.
+ * tests/local.at (AT_CONFIGURE_AC): Reuse file, rather than
+ repeating inline definition of AC_STATE_SAVE.
+ (AT_CHECK_ENV): Factor code...
+ (_AT_CHECK_ENV): ...into shell function.
+ * tests/m4sh.at (AT_DATA_LINENO): Avoid churn in testsuite.
+
Handle shell comments in AT_CHECK.
* lib/autotest/general.m4 (_AT_DECIDE_TRACEABLE): Handle # in
test correctly. Latent bug in handling shell comment was first
# But if you are borrowing from this file for setting up autotest in your
# project, remember to distribute both testsuite and package.m4.
EXTRA_DIST = $(TESTSUITE_AT) local.at mktests.sh \
- atlocal.in wrapper.as
+ atlocal.in wrapper.as statesave.m4
# Running the uninstalled scripts. Build them upon `all', for the manpages.
noinst_SCRIPTS = $(wrappers)
# Create a full configure.ac running BODY, with a config header set up,
# AC_OUTPUT, and environment checking hooks.
m4_define([AT_CONFIGURE_AC],
-[AT_DATA_AUTOCONF([aclocal.m4],
-[[
-# AC_STATE_SAVE(FILE)
-# -------------------
-# Save the shell variables and directory listing. AT_CHECK_ENV uses these to
-# confirm that no test modifies variables outside the Autoconf namespace or
-# leaves temporary files. AT_CONFIG_CMP uses the variable dumps to confirm that
-# tests have the same side effects regardless of caching.
-#
-# The sed script duplicates uniq functionality (thanks to 'info sed
-# uniq' for the recipe), in order to avoid a MacOS 10.5 bug where
-# readdir can list a file multiple times in a rapidly changing
-# directory, while avoiding yet another fork.
-m4_defun([AC_STATE_SAVE],
-[(set) 2>&1 | sort >state-env.$][1
-ls | sed '/^at-/d;/^state-/d;/^config\./d
- h
- :b
- $b
- N
- /^\(.*\)\n\1$/ {
- g
- bb
- }
- $b
- P
- D' >state-ls.$][1
-])# AC_STATE_SAVE
-]])
-
-AT_DATA([configure.ac],
+[AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_HEADERS(config.h:config.hin)
AC_STATE_SAVE(before)]
cp "$abs_top_srcdir/build-aux/install-sh" \
"$abs_top_srcdir/build-aux/config.guess" \
"$abs_top_srcdir/build-aux/config.sub" .
+cp "$abs_top_srcdir/tests/statesave.m4" aclocal.m4
])# AT_CONFIGURE_AC
# | '$'=6908
#
m4_define([AT_CHECK_ENV],
-[# Compare directory listings.
+[m4_divert_once([PREPARE_TESTS], [_AT_CHECK_ENV])dnl
+AT_CHECK([at_check_env])])
+m4_define([_AT_CHECK_ENV],
+[AS_FUNCTION_DESCRIBE([at_check_env], [],
+[Compare the directory and environment state both before and after a run,
+and return non-zero status if they differ inappropriately.])
+at_check_env ()
+{
+# Compare directory listings.
test -f state-ls.before ||
AS_ERROR([state-ls.before not present])
-test -f state-ls.after && { AT_CMP([state-ls.before], [state-ls.after]) }
+test -f state-ls.after \
+ && { $at_diff state-ls.before state-ls.after || return 1; }
# Compare variable space dumps.
if test -f state-env.before && test -f state-env.after; then
for act_file in state-env.before state-env.after
# There may be variables spread on several lines; remove latter lines.
$GREP '^m4_defn([m4_re_word])=' >clean-$act_file
done
- AT_CMP([clean-state-env.before], [clean-state-env.after])
+ $at_diff clean-state-env.before clean-state-env.after
fi
-])
+} [#]at_check_env])
# AT_CONFIG_CMP(VAR-FILE-A, VAR-FILE-B)
AT_BANNER([M4sh.])
-# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
-# Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+# 2009 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
AS@&t@_ERROR([cannot find original script])
exit 0
]])
-# If occurrences of $LINENO or __oline__ were wanted, create them.
+# If occurrences of $LINENO or __@&t@oline__ were wanted, create them.
sed 's/__LINENO__/$''LINENO/g;s/__OLINE__/__''oline__/g' $1.tas >$1.as
AT_CHECK([autom4te -l m4sh $1.as -o $1])
])# AT_DATA_LINENO
--- /dev/null
+# statesave.m4 serial 1
+
+# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+# 2009 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AC_STATE_SAVE(FILE)
+# -------------------
+# Save the shell variables and directory listing. AT_CHECK_ENV uses these to
+# confirm that no test modifies variables outside the Autoconf namespace or
+# leaves temporary files. AT_CONFIG_CMP uses the variable dumps to confirm
+# that tests have the same side effects regardless of caching.
+#
+# The sed script duplicates uniq functionality (thanks to 'info sed
+# uniq' for the recipe), in order to avoid a MacOS 10.5 bug where
+# readdir can list a file multiple times in a rapidly changing
+# directory, while avoiding yet another fork.
+m4_defun([AC_STATE_SAVE],
+[(set) 2>&1 | sort >state-env.$1
+ls | sed '/^at-/d;/^state-/d;/^config\./d
+ h
+ :b
+ $b
+ N
+ /^\(.*\)\n\1$/ {
+ g
+ bb
+ }
+ $b
+ P
+ D' >state-ls.$1
+])# AC_STATE_SAVE