From: Stefano Lattarini Date: Mon, 8 Aug 2011 21:35:28 +0000 (+0200) Subject: test defs: test directory creation more configurable X-Git-Tag: v1.11b~257^2~120 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e3b6255fbf58b9120f1df8f91480749def57cec1;p=platform%2Fupstream%2Fautomake.git test defs: test directory creation more configurable After this change, the individual tests will be able to tell `./defs' whether or not to create a temporary test directory for them, and if yes, whether or not to pre-populate it. * tests/defs: Only create the temporary test directory if the variable `$am_create_testdir' is not set to "no". In this case, only pre-populate it if that variable is not set to `$empty'. * tests/defs-static.in: Check that `$am_create_testdir' is not exported in the environment. * tests/self-check-env-sanitize.test: Update. * tests/self-check-dir.test: Extend, and make deeper and more robust. * tests/README (Section "Writing test cases" subsection "Do"): Update. * tests/autodist.test: Set `$am_create_testdir' instead of removing by hand files created by ./defs. * tests/tap-doc2.test: Likewise. --- diff --git a/ChangeLog b/ChangeLog index e0f922a..71611ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2011-08-09 Stefano Lattarini + + test defs: test directory creation more configurable + After this change, the individual tests will be able to tell + `./defs' whether or not to create a temporary test directory + for them, and if yes, whether or not to pre-populate it. + * tests/defs: Only create the temporary test directory if the + variable `$am_create_testdir' is not set to "no". In this + case, only pre-populate it if that variable is not set to + `$empty'. + * tests/defs-static.in: Check that `$am_create_testdir' is not + exported in the environment. + * tests/self-check-env-sanitize.test: Update. + * tests/self-check-dir.test: Extend, and make deeper and more + robust. + * tests/README (Section "Writing test cases" subsection "Do"): + Update. + * tests/autodist.test: Set `$am_create_testdir' instead of + removing by hand files created by ./defs. + * tests/tap-doc2.test: Likewise. + 2011-08-08 Stefano Lattarini testsuite: more uses of the `seq_' function diff --git a/tests/README b/tests/README index 8b8da14..54ec670 100644 --- a/tests/README +++ b/tests/README @@ -191,11 +191,14 @@ Do should be very very few), set the shell variable `parallel_tests' to "no" before including ./defs. - ./defs sets a skeleton configure.in. If possible, append to this - file. In some cases you'll have to overwrite it, but this should - be the exception. Note that configure.in registers Makefile.in - but do not output anything by default. If you need ./configure - to create Makefile, append AC_OUTPUT to configure.in. + ./defs brings in some commonly required files, and sets a skeleton + configure.in. If possible, append to this file. In some cases + you'll have to overwrite it, but this should be the exception. Note + that configure.in registers Makefile.in but do not output anything by + default. If you need ./configure to create Makefile, append AC_OUTPUT + to configure.in. In case you don't want ./defs to pre-populate your + test directory (which is a rare occurrence), set `$am_create_destdir' + to "empty" before sourcing ./defs. By default, the testcases are run with the `errexit' shell flag on, to make it easier to catch failures you might not have thought of. diff --git a/tests/autodist.test b/tests/autodist.test index f2b31ab..ed8dcc3 100755 --- a/tests/autodist.test +++ b/tests/autodist.test @@ -19,13 +19,9 @@ # Related to automake bug#7819. # Keep this test in sync with sister test `autodist-subdir.test'. +am_create_testdir=empty . ./defs || Exit 1 -# Ensure we are run from the right directory. -# (The last thing we want is to delete some random user files.) -test -f ../defs-static && test -f ../defs || Exit 99 -rm -f * - cat > configure.in < configure.in fi - echo "AC_CONFIG_FILES([Makefile])" -} >configure.in +fi ## ---------------- ## ## Ready to go... ## diff --git a/tests/defs-static.in b/tests/defs-static.in index 62f7486..0a7b77a 100644 --- a/tests/defs-static.in +++ b/tests/defs-static.in @@ -75,6 +75,7 @@ for var in \ required \ use_tap \ parallel_tests \ + am_create_testdir \ test_prefer_config_shell \ original_AUTOMAKE \ original_ACLOCAL \ diff --git a/tests/self-check-dir.test b/tests/self-check-dir.test index 0b4dd4e..1aae601 100755 --- a/tests/self-check-dir.test +++ b/tests/self-check-dir.test @@ -16,26 +16,51 @@ # Sanity check for the automake testsuite. # Check that tests using `./defs' create a proper temporary directory, -# and run in it. +# and run in it. Also check that we can prevent the pre-population +# and the creation of such directory if we want. . ./defs-static || exit 1 set -ex - AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC -this=S_dir -outcome=: -pwd +# This needs to be consistent with what $SHELL deems to be the +# current working directory. +cwd=`$SHELL -c 'pwd'` || exit 99 +echo "$cwd" + +rm -f _self.tmp -rm -f $this.tmp +st=0 +$SHELL -c ' + . ./defs || Exit 1 + pwd; ls -l; # For debugging. + : > _self.tmp + test -f install-sh + test -f configure.in + case `pwd` in '"$cwd"'/_self.dir);; *) Exit 1;; esac +' _self.test || st=1 +test -f _self.tmp && { rm -f _self.tmp; st=1; } +test $st -eq 0 || exit 1 -$SHELL -c " +st=0 +$SHELL -c ' + am_create_testdir=empty . ./defs || Exit 1 - : > $this.tmp - case \`pwd\` in '`pwd`'/$this.dir);; *) Exit 1;; esac -" $this.test || outcome=false + pwd; ls -l; # For debugging. + ls -a | grep -v "^\\.\\{1,2\\}$" | grep . && Exit 1 + : > _self.tmp + case `pwd` in '"$cwd"'/_self.dir);; *) Exit 1;; esac + : +' _self.test || st=1 +test -f _self.tmp && { rm -f _self.tmp; st=1; } +test $st -eq 0 || exit 1 -test -f $this.tmp && { rm -f $this.tmp; outcome=false; } +$SHELL -c ' + am_create_testdir=no + . ./defs || Exit 1 + test -f self-check-dir.test + case `pwd` in '"$cwd"');; *) Exit 1;; esac +' _self.test || exit 1 -$outcome +: diff --git a/tests/self-check-env-sanitize.test b/tests/self-check-env-sanitize.test index e2d8f2a..a7c66de 100755 --- a/tests/self-check-env-sanitize.test +++ b/tests/self-check-env-sanitize.test @@ -28,6 +28,7 @@ vars=' parallel_tests required use_tap + am_create_testdir test_prefer_config_shell original_AUTOMAKE original_ACLOCAL diff --git a/tests/tap-doc2.test b/tests/tap-doc2.test index 63bdc23..45d09ca 100755 --- a/tests/tap-doc2.test +++ b/tests/tap-doc2.test @@ -18,14 +18,10 @@ # See section "Using the TAP test protocol", subsection "Use TAP # with the Automake test harness". +am_create_testdir=empty parallel_tests=yes . ./defs || Exit 1 -# Ensure we are run from the right directory. -# (The last thing we want is to delete some random user files.) -test -f ../defs-static && test -f ../defs || Exit 99 -rm -f * - cat > Makefile.am <<'END' TEST_LOG_DRIVER = $(PERL) $(srcdir)/build-aux/tap-driver TESTS = foo.test bar.test baz.test