]> Sergey Matveev's repositories - zsh-autoenv.git/blobdiff - tests/recurse-upwards.t
tests: setup for multiple ZDOTDIRs, fix/add "setopt clobber"
[zsh-autoenv.git] / tests / recurse-upwards.t
index 8d94bf349d6b0072742b97a7e05f312aafacee8c..3e6067e284b197831472fc1e7d03f317646416e5 100644 (file)
@@ -8,18 +8,18 @@ Setup env actions / output.
 
 Create env files in root dir.
 
-  $ echo 'echo ENTERED_root: PWD:${PWD:t} from:${_autoenv_from_dir:t} to:${_autoenv_to_dir:t}' > .env
-  $ echo 'echo LEFT_root: PWD:${PWD:t} from:${_autoenv_from_dir:t} to:${_autoenv_to_dir:t}' > .env.leave
+  $ echo 'echo ENTERED_root: PWD:${PWD:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t}' > .env
+  $ echo 'echo LEFT_root: PWD:${PWD:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t}' > .env.leave
   $ test_autoenv_auth_env_files
 
 Create env files in sub dir.
 
   $ mkdir -p sub/sub2
   $ cd sub
-  ENTERED_root: PWD:sub from:recurse-upwards.t to:sub
+  ENTERED_root: PWD:recurse-upwards.t from:recurse-upwards.t to:sub
 
-  $ echo 'echo ENTERED_sub: PWD:${PWD:t} from:${_autoenv_from_dir:t} to:${_autoenv_to_dir:t}' > .env
-  $ echo 'echo LEFT_sub: PWD:${PWD:t} from:${_autoenv_from_dir:t} to:${_autoenv_to_dir:t}' > .env.leave
+  $ echo 'echo ENTERED_sub: PWD:${PWD:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t}' > .env
+  $ echo 'echo LEFT_sub: PWD:${PWD:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t}' > .env.leave
   $ test_autoenv_auth_env_files
 
 The actual tests.
@@ -31,7 +31,7 @@ The actual tests.
   LEFT_sub: PWD:sub from:sub to:recurse-upwards.t
 
   $ cd sub/sub2
-  ENTERED_sub: PWD:sub2 from:recurse-upwards.t to:sub2
+  ENTERED_sub: PWD:sub from:recurse-upwards.t to:sub2
 
   $ cd ..
 
@@ -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,11 +109,12 @@ Changing the root .env should trigger re-authentication via autoenv_source_paren
 
 First, let's answer "no".
 
-  $ echo "echo NEW" > .env
-  $ _autoenv_read_answer() { echo 'n' }
+  $ echo "echo NEW" >| .env
+  $ _autoenv_ask_for_yes() { echo "no"; return 1 }
   $ cd sub
   autoenv_source_parent_from_sub:
-  Attempting to load unauthorized env file: /tmp/cramtests-*/recurse-upwards.t/.env (glob)
+  Attempting to load unauthorized env file!
+  -* /tmp/cramtests-*/recurse-upwards.t/.env (glob)
   
   **********************************************
   
@@ -121,7 +122,7 @@ First, let's answer "no".
   
   **********************************************
   
-  Would you like to authorize it? [y/N] 
+  Would you like to authorize it? (type 'yes') no
   ENTERED_sub: PWD:sub from:recurse-upwards.t to:sub
   ENTER2
   done_sub
@@ -129,7 +130,7 @@ First, let's answer "no".
 Now with "yes".
 This currently does not trigger re-execution of the .env file.
 
-  $ _autoenv_read_answer() { echo 'y' }
+  $ _autoenv_ask_for_yes() { echo "yes"; return 0 }
   $ cd .
 
 Touching the .env file will now source the parent env file.
@@ -137,7 +138,8 @@ Touching the .env file will now source the parent env file.
   $ touch -t 201401010104 .env
   $ cd .
   autoenv_source_parent_from_sub:
-  Attempting to load unauthorized env file: /tmp/cramtests-*/recurse-upwards.t/.env (glob)
+  Attempting to load unauthorized env file!
+  -* /tmp/cramtests-*/recurse-upwards.t/.env (glob)
   
   **********************************************
   
@@ -145,8 +147,21 @@ Touching the .env file will now source the parent env file.
   
   **********************************************
   
-  Would you like to authorize it? [y/N] 
+  Would you like to authorize it? (type 'yes') yes
   NEW
   ENTERED_sub: PWD:sub from:sub to:sub
   ENTER2
   done_sub
+
+
+  $ cd ..
+  LEFT_sub: PWD:sub from:sub to:recurse-upwards.t
+  $ mkdir sub/sub2/sub3
+  $ cd sub/sub2/sub3
+  autoenv_source_parent_from_sub2:
+  autoenv_source_parent_from_sub:
+  NEW
+  ENTERED_sub: PWD:sub from:recurse-upwards.t to:sub
+  ENTER2
+  done_sub
+  done_sub2