self tests: check that `$me' can be overridden
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 5 Jun 2011 18:58:21 +0000 (20:58 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 8 Jun 2011 07:58:11 +0000 (09:58 +0200)
* tests/self-check-me.test: Check that `$me' can be overridden
before sourcing ./defs, with or without sourcing ./defs-static
beforehand, and that this override is honored.  Update heading
comments.

ChangeLog
tests/self-check-me.test

index 569f44a..c57e2c5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-06-05  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       self tests: check that `$me' can be overridden
+       * tests/self-check-me.test: Check that `$me' can be overridden
+       before sourcing ./defs, with or without sourcing ./defs-static
+       beforehand, and that this override is honored.  Update heading
+       comments.
+
 2011-06-02  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        self tests: fix another spurious failure
index 8fd2bc0..e8b1361 100755 (executable)
@@ -15,7 +15,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Sanity check for the automake testsuite.
-# Make sure that $me gets automatically defined by `./defs'.
+# Make sure that $me gets automatically defined by `./defs', and that it
+# can be overridden by the test script.
 
 . ./defs-static || exit 1
 
@@ -29,4 +30,16 @@ $SHELL -c '. ./defs && echo me=$me' 012.test | grep '^me=012$'
 $SHELL -c '. ./defs && echo me=$me' foo.bar | grep '^me=foo\.bar$'
 $SHELL -c '. ./defs && echo me=$me' a.b.c.test | grep '^me=a\.b\.c$'
 
+# Overriding $me after sourcing ./defs-static should work.
+s=`$SHELL -c '. ./defs-static && me=zardoz && . ./defs && echo me=$me' \
+             bad.test` || exit 1
+printf '%s\n' "$s" | grep '^me=zardoz$'
+printf '%s\n' "$s" | grep 'me=bad' && exit 1
+
+# If we override $me, ./defs should not modify it.
+s=`$SHELL -c 'me=foo.test && . ./defs && echo me=$me' \
+             bad.test` || exit 1
+printf '%s\n' "$s" | grep '^me=foo\.test$'
+printf '%s\n' "$s" | grep 'me=bad' && exit 1
+
 :