]> Sergey Matveev's repositories - zsh-autoenv.git/commitdiff
tests: setup for multiple ZDOTDIRs, fix/add "setopt clobber"
authorDaniel Hahler <git@thequod.de>
Mon, 8 Dec 2014 21:12:30 +0000 (22:12 +0100)
committerDaniel Hahler <git@thequod.de>
Mon, 8 Dec 2014 21:14:54 +0000 (22:14 +0100)
.travis.yml
Makefile
autoenv.zsh
tests/ZDOTDIR.clobber/.zshenv [new file with mode: 0644]
tests/ZDOTDIR/.zshenv [moved from tests/.zshenv with 100% similarity]
tests/autoenv.t
tests/leave.t
tests/recurse-upwards.t
tests/setup.sh
tests/varstash.t

index 00828baa65aa19671dbde96986c73237ccc70e9a..715854b03dd001944099cfcdc0cf7c693843e5ab 100644 (file)
@@ -4,4 +4,4 @@ python:
 before_script:
   - "sudo apt-get install zsh"
 install: "sudo pip install cram"
-script: "make test"
+script: "make test_full"
index 0ffe150a521014dcf2cbfc706fd7fbdbd8736800..db303fa3d6353efeb0f0f680c85fb28536de0504 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,17 @@
-.PHONY: itest test
+export ZDOTDIR=${PWD}/tests/ZDOTDIR
 
 test:
-       ZDOTDIR="${PWD}/tests" cram --shell=zsh -v tests
+       cram --shell=zsh -v tests
 
 itest:
-       ZDOTDIR="${PWD}/tests" cram -i --shell=zsh tests
+       cram -i --shell=zsh tests
+
+# Run tests with all ZDOTDIRs.
+test_full:
+       for i in $(wildcard tests/ZDOTDIR*); do \
+               echo "ZDOTDIR=$$i"; \
+               ZDOTDIR=${PWD}/$$i cram --shell=zsh -v tests; \
+       done
 
 # Define targets for test files, with relative and abolute path.
 # Use verbose output, which is useful with Vim's 'errorformat'.
@@ -15,3 +22,5 @@ _TESTS_REL_AND_ABS:=$(call uniq,$(abspath $(TESTS)) $(TESTS))
 $(_TESTS_REL_AND_ABS):
        ZDOTDIR="${PWD}/tests" cram --shell=zsh -v $@
 .PHONY: $(_TESTS_REL_AND_ABS)
+
+.PHONY: itest test
index 8bc39bfd3c8356cb9ec01e050921da6915281305..e8d0b99e4eecff85dd86fff8e841b2e465188888 100644 (file)
@@ -147,7 +147,7 @@ _autoenv_authorized_env_file() {
 _autoenv_authorize() {
   local env_file=${1:A}
   _autoenv_deauthorize $env_file
-  _autoenv_hash_pair $env_file >> $AUTOENV_ENV_FILENAME
+  _autoenv_hash_pair $env_file >>| $AUTOENV_ENV_FILENAME
 }
 
 # Deauthorize a given filename, by removing it from the auth file.
@@ -156,7 +156,7 @@ _autoenv_authorize() {
 _autoenv_deauthorize() {
   local env_file=${1:A}
   if [[ -s $AUTOENV_ENV_FILENAME ]]; then
-    echo "$(\grep -vF :${env_file}: $AUTOENV_ENV_FILENAME)" > $AUTOENV_ENV_FILENAME
+    echo "$(\grep -vF :${env_file}: $AUTOENV_ENV_FILENAME)" >| $AUTOENV_ENV_FILENAME
   fi
 }
 
diff --git a/tests/ZDOTDIR.clobber/.zshenv b/tests/ZDOTDIR.clobber/.zshenv
new file mode 100644 (file)
index 0000000..62037dc
--- /dev/null
@@ -0,0 +1,3 @@
+source ${ZDOTDIR}/../ZDOTDIR/.zshenv
+
+setopt noclobber
similarity index 100%
rename from tests/.zshenv
rename to tests/ZDOTDIR/.zshenv
index 701e3b463967d21abb56e773929655f6d8ad343d..aef6bb927cc7c3b5a981edcd8d190f1fe4b8c38d 100644 (file)
@@ -2,7 +2,7 @@
 
 Lets set a simple .env action
 
-  $ echo 'echo ENTERED' >> .env
+  $ echo 'echo ENTERED' > .env
 
 Manually create auth file
 
index 2e4e36089d730aebd92e52405bb288ab0d6bb638..227da714f0c52370429c0de045ab66867d66701b 100644 (file)
@@ -4,8 +4,8 @@ Lets set a simple .env action
 
   $ mkdir sub
   $ cd sub
-  $ echo 'echo ENTERED' >> .env
-  $ echo 'echo LEFT' >> .env.leave
+  $ echo 'echo ENTERED' > .env
+  $ echo 'echo LEFT' > .env.leave
 
 Change to the directory.
 
index aa36edd22d43db5807ccf25eb04fa2aa35e97207..3e6067e284b197831472fc1e7d03f317646416e5 100644 (file)
@@ -86,7 +86,7 @@ Prepend call to autoenv_source_parent to sub/.env file.
 
 Add sub/sub2/.env file.
 
-  $ echo -e "echo autoenv_source_parent_from_sub2:\nautoenv_source_parent\necho done_sub2\n" > sub2/.env
+  $ echo -e "echo autoenv_source_parent_from_sub2:\nautoenv_source_parent\necho done_sub2\n" >| sub2/.env
   $ test_autoenv_add_to_env sub2/.env
   $ cd sub2
   autoenv_source_parent_from_sub2:
@@ -109,7 +109,7 @@ Changing the root .env should trigger re-authentication via autoenv_source_paren
 
 First, let's answer "no".
 
-  $ echo "echo NEW" > .env
+  $ echo "echo NEW" >| .env
   $ _autoenv_ask_for_yes() { echo "no"; return 1 }
   $ cd sub
   autoenv_source_parent_from_sub:
index 5c6ae9eb6173c7eb31c9145e0b1f0fa357fb17b9..557b9e77cb5f471f13a57ef5206b09e099fa7ad1 100644 (file)
@@ -8,11 +8,11 @@
 [[ $AUTOENV_ENV_FILENAME[0,4] == '/tmp' ]] || return 1
 
 # Reset any authentication.
-echo -n > $AUTOENV_ENV_FILENAME
+echo -n >| $AUTOENV_ENV_FILENAME
 
 # Add file $1 (with optional hash $2) to authentication file.
 test_autoenv_add_to_env() {
-  _autoenv_hash_pair $1 ${2:-} >> $AUTOENV_ENV_FILENAME
+  _autoenv_hash_pair $1 ${2:-} >>| $AUTOENV_ENV_FILENAME
 }
 
 # Add enter and leave env files to authentication file.
index cdb47a8d30894e9e9fb34471a5e86571941335a7..487230b5d8bfb42c050d789a94e8a5d1ace47fd8 100644 (file)
@@ -39,8 +39,8 @@ Setup:
   $ unset VAR
   $ cd sub
   ENTER
-  $ echo 'echo ENTER; autostash VAR=changed' > $AUTOENV_FILE_ENTER
-  $ echo 'echo LEAVE; echo "no explicit call to autounstash"' > $AUTOENV_FILE_LEAVE
+  $ echo 'echo ENTER; autostash VAR=changed' >| $AUTOENV_FILE_ENTER
+  $ echo 'echo LEAVE; echo "no explicit call to autounstash"' >| $AUTOENV_FILE_LEAVE
   $ test_autoenv_auth_env_files
 
 $VAR is unset: