From: Akim Demaille Date: Fri, 11 May 2012 14:55:30 +0000 (+0200) Subject: tests: AT_SAVE_SPECIAL_FILES / AT_RESTORE_SPECIAL_FILES. X-Git-Tag: v2.5.1_rc2~13 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/5192fd5d508ba4bf1bf4aabb59861f9227e99f09?hp=7f7fdba418c416d106a996c4d88eb9c57146ae75 tests: AT_SAVE_SPECIAL_FILES / AT_RESTORE_SPECIAL_FILES. 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. --- diff --git a/tests/local.at b/tests/local.at index 7e88408f..ee451ad5 100644 --- a/tests/local.at +++ b/tests/local.at @@ -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 ]]) ])