1 Test recursing into parent .autoenv.zsh files.
3 $ source $TESTDIR/setup.zsh || return 1
5 Setup env actions / output.
7 $ AUTOENV_LOOK_UPWARDS=1
9 Create env files in root dir.
11 $ echo 'echo ENTERED_root: PWD:${PWD:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t}' > .autoenv.zsh
12 $ echo 'echo LEFT_root: PWD:${PWD:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t}' > .autoenv_leave.zsh
13 $ test_autoenv_auth_env_files
15 Create env files in sub dir.
19 ENTERED_root: PWD:sub from:recurse-upwards.t to:sub
21 $ echo 'echo ENTERED_sub: PWD:${PWD:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t}' > .autoenv.zsh
22 $ echo 'echo LEFT_sub: PWD:${PWD:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t}' > .autoenv_leave.zsh
23 $ test_autoenv_auth_env_files
28 ENTERED_sub: PWD:sub from:sub to:sub
31 LEFT_sub: PWD:recurse-upwards.t from:sub to:recurse-upwards.t
34 ENTERED_sub: PWD:sub2 from:recurse-upwards.t to:sub2
38 Changing the .autoenv.zsh file should re-source it.
40 $ echo 'echo ENTER2' >> .autoenv.zsh
42 Set timestamp of auth file into the past, so it gets seen as new below.
44 $ touch -t 201401010101 .autoenv.zsh
46 $ test_autoenv_auth_env_files
48 ENTERED_sub: PWD:sub from:sub to:sub
51 Add sub/sub2/.autoenv.zsh file, with a call to autoenv_source_parent.
53 $ echo "echo autoenv_source_parent_from_sub2:\nautoenv_source_parent\necho done_sub2\n" > sub2/.autoenv.zsh
54 $ test_autoenv_add_to_env sub2/.autoenv.zsh
56 autoenv_source_parent_from_sub2:
57 ENTERED_sub: PWD:sub2 from:sub to:sub2
61 Move sub/.autoenv.zsh away, now the root .autoenv.zsh file should get sourced.
63 $ mv ../.autoenv.zsh ../.autoenv.zsh.out
64 $ touch -t 201401010102 .autoenv.zsh
66 autoenv_source_parent_from_sub2:
67 ENTERED_root: PWD:sub2 from:sub2 to:sub2
69 $ mv ../.autoenv.zsh.out ../.autoenv.zsh
71 Prepend call to autoenv_source_parent to sub/.autoenv.zsh file.
74 $ sed -i -e "1s/^/echo autoenv_source_parent_from_sub:\nautoenv_source_parent\n/" .autoenv.zsh
75 $ echo "echo done_sub" >> .autoenv.zsh
76 $ touch -t 201401010103 .autoenv.zsh
77 $ test_autoenv_auth_env_files
80 autoenv_source_parent_from_sub:
81 ENTERED_root: PWD:sub from:sub to:sub
82 ENTERED_sub: PWD:sub from:sub to:sub
87 Add sub/sub2/.autoenv.zsh file.
89 $ echo -e "echo autoenv_source_parent_from_sub2:\nautoenv_source_parent\necho done_sub2\n" >| sub2/.autoenv.zsh
90 $ test_autoenv_add_to_env sub2/.autoenv.zsh
92 autoenv_source_parent_from_sub2:
93 autoenv_source_parent_from_sub:
94 ENTERED_root: PWD:sub2 from:sub to:sub2
95 ENTERED_sub: PWD:sub2 from:sub to:sub2
101 This should not trigger the enter event, because it was handled via
102 autoenv_source_parent already.
105 LEFT_sub: PWD:recurse-upwards.t from:sub2 to:recurse-upwards.t
108 Changing the root .autoenv.zsh should trigger re-authentication via
109 autoenv_source_parent.
111 First, let's answer "no".
113 $ echo "echo NEW" >| .autoenv.zsh
114 $ _autoenv_ask_for_yes() { echo "no"; return 1 }
116 autoenv_source_parent_from_sub:
117 Attempting to load unauthorized env file!
118 -* /tmp/cramtests-*/recurse-upwards.t/.autoenv.zsh (glob)
120 **********************************************
124 **********************************************
126 Would you like to authorize it? (type 'yes') no
127 ENTERED_sub: PWD:sub from:recurse-upwards.t to:sub
132 This currently does not trigger re-execution of the .autoenv.zsh file.
134 $ _autoenv_ask_for_yes() { echo "yes"; return 0 }
137 Touching the .autoenv.zsh file will now source the parent env file.
139 $ touch -t 201401010104 .autoenv.zsh
141 autoenv_source_parent_from_sub:
142 Attempting to load unauthorized env file!
143 -* /tmp/cramtests-*/recurse-upwards.t/.autoenv.zsh (glob)
145 **********************************************
149 **********************************************
151 Would you like to authorize it? (type 'yes') yes
153 ENTERED_sub: PWD:sub from:sub to:sub
159 LEFT_sub: PWD:recurse-upwards.t from:sub to:recurse-upwards.t
160 $ mkdir sub/sub2/sub3
162 autoenv_source_parent_from_sub2:
163 autoenv_source_parent_from_sub:
165 ENTERED_sub: PWD:sub3 from:recurse-upwards.t to:sub3