]> Sergey Matveev's repositories - zsh-autoenv.git/blob - tests/_autoenv_stack.t
Some more refactoring, adding support for `autoenv_source_parent`
[zsh-autoenv.git] / tests / _autoenv_stack.t
1 Tests for internal stack handling.
2
3   $ source $TESTDIR/setup.sh
4
5 Non-existing entries are allowed and handled without error.
6
7   $ _autoenv_stack_entered_add non-existing
8   $ echo $_autoenv_stack_entered
9   non-existing
10
11 Add existing entries.
12
13   $ mkdir -p sub/sub2
14   $ touch -t 201401010101 sub/file
15   $ _autoenv_stack_entered_add sub
16   $ _autoenv_stack_entered_add sub/file
17   $ _autoenv_stack_entered_add sub/sub2
18   $ echo $_autoenv_stack_entered
19   non-existing sub sub/file sub/sub2
20
21   $ _autoenv_stack_entered_add non-existing
22   $ echo $_autoenv_stack_entered
23   sub sub/file sub/sub2 non-existing
24
25   $ echo ${(k)_autoenv_stack_entered}
26   sub sub/file sub/sub2 non-existing
27
28   $ echo $_autoenv_stack_entered_mtime
29   0 1388538060 0 0 (glob)
30
31 Touch the file and re-add it.
32
33   $ touch -t 201401012359 sub/file
34   $ _autoenv_stack_entered_add sub/file
35
36 The mtime should have been updated.
37
38   $ echo ${_autoenv_stack_entered_mtime[sub/file]}
39   1388620740
40
41 It should have moved to the end of the stack.
42
43   $ echo ${(k)_autoenv_stack_entered}
44   sub sub/sub2 non-existing sub/file
45
46 Test lookup of containing elements.
47
48   $ _autoenv_stack_entered_contains sub/file
49   $ _autoenv_stack_entered_contains non-existing
50   $ _autoenv_stack_entered_contains not-added
51   [1]
52