2014-11-15 21:59:39 +02:00
|
|
|
Test varstash integration.
|
|
|
|
|
|
|
|
$ source $TESTDIR/setup.sh
|
|
|
|
|
|
|
|
Setup test environment.
|
|
|
|
|
|
|
|
$ mkdir sub
|
|
|
|
$ cd sub
|
2014-12-04 06:36:12 +02:00
|
|
|
$ echo 'echo ENTER; autostash FOO=changed' > $AUTOENV_FILE_ENTER
|
2014-11-24 18:48:51 +02:00
|
|
|
$ echo 'echo LEAVE; autounstash' > $AUTOENV_FILE_LEAVE
|
2014-11-15 21:59:39 +02:00
|
|
|
|
|
|
|
Manually create auth file
|
|
|
|
|
2014-11-22 00:07:53 +02:00
|
|
|
$ test_autoenv_auth_env_files
|
2014-11-15 21:59:39 +02:00
|
|
|
|
|
|
|
Set environment variable.
|
|
|
|
|
2014-12-04 06:36:12 +02:00
|
|
|
$ FOO=orig
|
2014-11-15 21:59:39 +02:00
|
|
|
|
|
|
|
Activating the env stashes it and applies a new value.
|
|
|
|
|
|
|
|
$ cd .
|
2014-11-24 18:48:51 +02:00
|
|
|
ENTER
|
2014-11-15 21:59:39 +02:00
|
|
|
$ echo $FOO
|
2014-12-04 06:36:12 +02:00
|
|
|
changed
|
2014-11-15 21:59:39 +02:00
|
|
|
|
|
|
|
Leaving the directory unstashes it.
|
|
|
|
|
|
|
|
$ cd ..
|
2014-11-24 18:48:51 +02:00
|
|
|
LEAVE
|
2014-11-15 21:59:39 +02:00
|
|
|
$ echo $FOO
|
2014-12-04 06:36:12 +02:00
|
|
|
orig
|
|
|
|
|
|
|
|
|
|
|
|
Test autounstashing when leaving a directory. {{{
|
|
|
|
|
|
|
|
Setup:
|
|
|
|
|
2014-12-08 22:37:25 +02:00
|
|
|
$ unset VAR
|
2014-12-04 06:36:12 +02:00
|
|
|
$ cd sub
|
|
|
|
ENTER
|
2014-12-08 23:12:30 +02:00
|
|
|
$ echo 'echo ENTER; autostash VAR=changed' >| $AUTOENV_FILE_ENTER
|
|
|
|
$ echo 'echo LEAVE; echo "no explicit call to autounstash"' >| $AUTOENV_FILE_LEAVE
|
2014-12-04 06:36:12 +02:00
|
|
|
$ test_autoenv_auth_env_files
|
|
|
|
|
2014-12-08 22:37:25 +02:00
|
|
|
$VAR is unset:
|
2014-12-04 06:36:12 +02:00
|
|
|
|
2014-12-08 22:37:25 +02:00
|
|
|
$ echo VAR_set:$+VAR
|
|
|
|
VAR_set:0
|
2014-12-04 06:36:12 +02:00
|
|
|
|
2014-12-08 22:37:25 +02:00
|
|
|
Trigger the autostashing in the enter file.
|
2014-12-04 06:36:12 +02:00
|
|
|
|
|
|
|
$ cd ..
|
|
|
|
LEAVE
|
|
|
|
no explicit call to autounstash
|
|
|
|
$ cd sub
|
|
|
|
ENTER
|
|
|
|
$ echo $VAR
|
|
|
|
changed
|
|
|
|
|
|
|
|
Now leave again.
|
|
|
|
|
|
|
|
$ cd ..
|
|
|
|
LEAVE
|
|
|
|
no explicit call to autounstash
|
2014-12-08 22:37:25 +02:00
|
|
|
$ echo VAR_set:$+VAR
|
|
|
|
VAR_set:0
|
2014-12-04 06:36:12 +02:00
|
|
|
|
|
|
|
Remove the leave file, auto-unstashing should still happen.
|
|
|
|
|
|
|
|
$ rm sub/$AUTOENV_FILE_LEAVE
|
|
|
|
$ cd sub
|
|
|
|
ENTER
|
|
|
|
$ echo $VAR
|
|
|
|
changed
|
|
|
|
$ cd ..
|
2014-12-08 22:37:25 +02:00
|
|
|
$ echo VAR_set:$+VAR
|
|
|
|
VAR_set:0
|
|
|
|
|
|
|
|
And once again where a value gets restored.
|
|
|
|
|
|
|
|
$ VAR=orig_2
|
2014-12-04 06:36:12 +02:00
|
|
|
$ echo $VAR
|
2014-12-08 22:37:25 +02:00
|
|
|
orig_2
|
|
|
|
$ cd sub
|
|
|
|
ENTER
|
|
|
|
$ echo $VAR
|
|
|
|
changed
|
|
|
|
$ cd ..
|
|
|
|
$ echo $VAR
|
|
|
|
orig_2
|
2014-12-04 06:36:12 +02:00
|
|
|
|
|
|
|
}}}
|