]> Sergey Matveev's repositories - zsh-autoenv.git/blob - tests/setup.sh
tests: setup.sh: doc / more verbose
[zsh-autoenv.git] / tests / setup.sh
1 # Setup for tests.
2 #
3 # It returns 1 in case of errors, and no tests should be run then!
4 #
5 # Ensure we have our mocked out AUTOENV_ENV_FILENAME
6 # (via .zshenv).
7
8 # Treat unset variables as errors.
9 # Not handled in varstash yet.
10 # setopt nounset
11
12 if [[ $AUTOENV_ENV_FILENAME[0,4] != '/tmp' ]]; then
13   echo "AUTOENV_ENV_FILENAME is not in /tmp. Aborting."
14   return 1
15 fi
16
17 # Reset any authentication.
18 echo -n >| $AUTOENV_ENV_FILENAME
19
20 # Add file $1 (with optional hash $2) to authentication file.
21 test_autoenv_add_to_env() {
22   _autoenv_hash_pair $1 ${2:-} >>| $AUTOENV_ENV_FILENAME
23 }
24
25 # Add enter and leave env files to authentication file.
26 test_autoenv_auth_env_files() {
27   test_autoenv_add_to_env $PWD/$AUTOENV_FILE_ENTER
28   test_autoenv_add_to_env $PWD/$AUTOENV_FILE_LEAVE
29 }