]> git.saurik.com Git - bison.git/commitdiff
tests: AT_SAVE_SPECIAL_FILES / AT_RESTORE_SPECIAL_FILES.
authorAkim Demaille <akim@lrde.epita.fr>
Fri, 11 May 2012 14:55:30 +0000 (16:55 +0200)
committerAkim Demaille <akim@lrde.epita.fr>
Fri, 11 May 2012 15:06:18 +0000 (17:06 +0200)
Some of our macros play with expout and other Autotest special files,
which may break their callers (e.g., currently TESTSUITEFLAGS='248
BISON_TEST_XML=1' fails).

There is already some support for this.  Expand it to be ready to use
it elsewhere.

* tests/local.at (AT_RESTORE_SPECIAL_FILES, AT_SAVE_SPECIAL_FILES)
(at_save_special_files, at_restore_special_files): New.
(AT_BISON_CHECK_NO_XML): Use them.

tests/local.at

index 7e88408fcd9c6abaa693967652b0555aa2276594..ee451ad553bbb78bb129270927acf517a251fd38 100644 (file)
@@ -37,6 +37,33 @@ printf "$count\n";' $1], [0], [$3
 ])])
 
 
+# AT_SAVE_SPECIAL_FILES / AT_RESTORE_SPECIAL_FILES
+# ------------------------------------------------
+# Don't interfere with caller's files.
+m4_divert_text([PREPARE_TESTS],
+[at_save_special_files ()
+{
+  for at_save_file in stderr experr expout
+  do
+    test ! -f $at_save_file || mv $at_save_file at-bison-check-$at_save_file.bak
+  done
+}
+
+at_restore_special_files ()
+{
+  for at_save_file in stderr experr expout
+  do
+    test ! -f at-bison-check-$at_save_file.bak ||
+      mv at-bison-check-$at_save_file.bak $at_save_file
+  done
+}
+])
+
+m4_define([AT_SAVE_SPECIAL_FILES],    [at_save_special_files])
+m4_define([AT_RESTORE_SPECIAL_FILES], [at_restore_special_files])
+
+
+
 ## ------------------------------- ##
 ## Macros decoding Bison options.  ##
 ## ------------------------------- ##
@@ -283,10 +310,7 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [],
         # are added after the grammar file name, so skip these checks
         # in that case.
         if test -z "${POSIXLY_CORRECT+set}"; then
-          # Don't interfere with caller's files.
-          if test -f stderr; then mv stderr at-bison-check-stderr.bak; fi
-          if test -f experr; then mv experr at-bison-check-experr.bak; fi
-          if test -f expout; then mv expout at-bison-check-expout.bak; fi
+          ]AT_SAVE_SPECIAL_FILES[
 
           # To avoid expanding it repeatedly, store specified stdout.
           ]AT_DATA([expout], [$3])[
@@ -338,16 +362,7 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [],
           ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=none \
                     -Werror]], [[0]], [expout])[
 
-          # Restore caller's files.
-          if test -f at-bison-check-expout.bak; then
-            mv at-bison-check-expout.bak expout
-          fi
-          if test -f at-bison-check-experr.bak; then
-            mv at-bison-check-experr.bak experr
-          fi
-          if test -f at-bison-check-stderr.bak; then
-            mv at-bison-check-stderr.bak stderr
-          fi
+          ]AT_RESTORE_SPECIAL_FILES[
         fi
       ]])
 ])