2014-11-15 21:59:39 +02:00
|
|
|
Test varstash integration.
|
|
|
|
|
2015-04-23 17:03:21 +03:00
|
|
|
$ source $TESTDIR/setup.zsh || return 1
|
2014-11-15 21:59:39 +02:00
|
|
|
|
|
|
|
Setup test environment.
|
|
|
|
|
|
|
|
$ mkdir sub
|
|
|
|
$ cd sub
|
|
|
|
|
2016-04-26 21:07:33 +03:00
|
|
|
The varstash library should not get loaded always.
|
2014-11-15 21:59:39 +02:00
|
|
|
|
2016-04-26 21:07:33 +03:00
|
|
|
$ echo 'echo ENTER' > $AUTOENV_FILE_ENTER
|
|
|
|
$ echo 'echo LEAVE' > $AUTOENV_FILE_LEAVE
|
|
|
|
$ test_autoenv_auth_env_files
|
|
|
|
$ cd .
|
|
|
|
ENTER
|
|
|
|
$ type -w autostash
|
|
|
|
autostash: none
|
|
|
|
[1]
|
|
|
|
|
|
|
|
Now on to some stashing.
|
|
|
|
|
|
|
|
$ echo 'echo ENTER; autostash FOO=changed' > $AUTOENV_FILE_ENTER
|
|
|
|
$ echo 'echo LEAVE; autounstash' > $AUTOENV_FILE_LEAVE
|
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.
|
|
|
|
|
2016-04-26 21:07:33 +03:00
|
|
|
$ cd ..
|
|
|
|
LEAVE
|
|
|
|
$ cd sub
|
2014-11-24 18:48:51 +02:00
|
|
|
ENTER
|
2016-04-26 21:07:33 +03:00
|
|
|
$ type -w autostash
|
|
|
|
autostash: function
|
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
|
|
|
|
|
|
|
}}}
|