From e120d4c7ec88b11a1fa09d5285c87f141de6c790 Mon Sep 17 00:00:00 2001
From: Akim Demaille <demaille@gostai.com>
Date: Mon, 20 Feb 2012 14:04:01 +0100
Subject: [PATCH] tests: check yacc parser header recovery in vpath builds.

* tests/yacc7.test (run_test): New function.
This is the former post-bootstrap part of the test.
Run it twice, once as before, then as a vpath build.
---
 tests/yacc7.test |   62 ++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 39 insertions(+), 23 deletions(-)

diff --git a/tests/yacc7.test b/tests/yacc7.test
index 64a536b..d5cfef4 100755
--- a/tests/yacc7.test
+++ b/tests/yacc7.test
@@ -56,35 +56,51 @@ END
 $ACLOCAL
 $AUTOMAKE -a
 $AUTOCONF
-./configure
 
-$MAKE foo.h
+# run_test BUILD-DIR
+# ------------------
+run_test ()
+{
+  if test x"$1" != x.; then
+    rm -rf "$1"
+    mkdir "$1"
+    cd "$1"
+    srcdir=..
+  else
+    srcdir=.
+  fi
+  $srcdir/configure
+
+  $MAKE foo.h
 
-test -f foo.h
+  test -f $srcdir/foo.h
 
-rm -f foo.h foo.c
-$MAKE check-dist
+  rm -f $srcdir/foo.h $srcdir/foo.c
+  $MAKE check-dist
 
-# We should be able to recover if foo.h is deleted.
+  # We should be able to recover if foo.h is deleted.
+  rm -f $srcdir/foo.h
+  $MAKE $srcdir/foo.h
+  test -f $srcdir/foo.h
 
-rm -f foo.h
-$MAKE foo.h
-test -f foo.h
+  # Make sure `#line ... y.tab.h' gets replaced.
+  $FGREP 'y.tab.h' $srcdir/foo.h && Exit 1
 
-# Make sure `#line ... y.tab.h' gets replaced.
-$FGREP 'y.tab.h' foo.h && Exit 1
+  # Make distclean must not erase foo.c nor foo.h (by GNU standards) ...
+  $MAKE $srcdir/foo.c
+  test -f $srcdir/foo.h
+  test -f $srcdir/foo.c
+  $MAKE distclean
+  test -f $srcdir/foo.h
+  test -f $srcdir/foo.c
+  # ... but maintainer-clean should.
+  $srcdir/configure # Re-create `Makefile'.
+  $MAKE maintainer-clean
+  test ! -f $srcdir/foo.h
+  test ! -f $srcdir/foo.c
+}
 
-# Make distclean must not erase foo.c nor foo.h (by GNU standards) ...
-$MAKE foo.c
-test -f foo.h
-test -f foo.c
-$MAKE distclean
-test -f foo.h
-test -f foo.c
-# ... but maintainer-clean should.
-./configure # Re-create `Makefile'.
-$MAKE maintainer-clean
-test ! -f foo.h
-test ! -f foo.c
+run_test .
+run_test _build
 
 :
-- 
1.7.9

