From ebef4c26133c38a7e8df848ee0243ff0308941a1 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 23 Apr 2015 16:00:12 +0200 Subject: [PATCH] tests: define/use $TEST_SOURCE_AUTOENV This handled (re)loading autoenv for ZDOTDIR=tests/ZDOTDIR.loadviafunction. --- tests/ZDOTDIR.loadviafunction/.zshenv | 1 - tests/autoenv.t | 2 +- tests/setup.sh | 8 ++++++-- tests/varstash_export.t | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/ZDOTDIR.loadviafunction/.zshenv b/tests/ZDOTDIR.loadviafunction/.zshenv index 4e41fbc..8f836b5 100644 --- a/tests/ZDOTDIR.loadviafunction/.zshenv +++ b/tests/ZDOTDIR.loadviafunction/.zshenv @@ -5,7 +5,6 @@ AUTOENV_DEBUG=0 antigen-like-loader-function() { source "$TESTDIR/../autoenv.plugin.zsh" } -antigen-like-loader-function export AUTOENV_ENV_FILENAME="$PWD/.env_auth" diff --git a/tests/autoenv.t b/tests/autoenv.t index 35cd963..67be7ca 100644 --- a/tests/autoenv.t +++ b/tests/autoenv.t @@ -91,5 +91,5 @@ Lets also try one more time to ensure it didn't add it. Reloading the script should keep the current state, e.g. when reloading your ~/.zshrc. - $ source $TEST_AUTOENV_PLUGIN_FILE + $ $TEST_SOURCE_AUTOENV $ cd . diff --git a/tests/setup.sh b/tests/setup.sh index 9e5cf7b..27ba423 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -18,8 +18,12 @@ fi _save_errexit=${options[errexit]} set -e -export TEST_AUTOENV_PLUGIN_FILE="$TESTDIR/../autoenv.plugin.zsh" -source $TEST_AUTOENV_PLUGIN_FILE +if (( ${+functions[antigen-like-loader-function]} )); then + TEST_SOURCE_AUTOENV=antigen-like-loader-function +else + TEST_SOURCE_AUTOENV=(source $TESTDIR/../autoenv.plugin.zsh) +fi +$TEST_SOURCE_AUTOENV # Reset any authentication. echo -n >| $AUTOENV_ENV_FILENAME diff --git a/tests/varstash_export.t b/tests/varstash_export.t index d666d66..2b75848 100644 --- a/tests/varstash_export.t +++ b/tests/varstash_export.t @@ -35,14 +35,14 @@ The variable is not available in a subshell, only the exported one. Activate autoenv in the subshell. - $ $SHELL -c 'source $TEST_AUTOENV_PLUGIN_FILE; echo ${MYVAR}; echo $MYEXPORT' + $ $SHELL -c "$TEST_SOURCE_AUTOENV; echo \${MYVAR}; echo \$MYEXPORT" ENTER changed changed_export "autounstash" should handle the exported variables. - $ $SHELL -c 'source $TEST_AUTOENV_PLUGIN_FILE; cd ..; echo ${MYVAR:-empty}; echo $MYEXPORT' + $ $SHELL -c "$TEST_SOURCE_AUTOENV; cd ..; echo \${MYVAR:-empty}; echo \$MYEXPORT" ENTER LEAVE empty