Skip to content

Commit d7d007f

Browse files
committed
Test the special wait'' syntax using a eval snippet, like e.g.: wait'[[ -n $var ]]'.
Also test plugin unloading of atload'!…' ice (tracked atload'' ice)
1 parent 1bb2d6c commit d7d007f

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

tests/plugins.zunit

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,41 @@
66
ZBIN=$ZPFX/bin
77
export LC_CTYPE=C
88
export LANG=C
9-
export ZTMP=$(mktemp -qu)
9+
export ZTMP=$(mktemp -qu) TMPQ=,
1010
}
1111

12-
@test 'wait-ice' {
12+
@test '(un)load-ices' {
13+
rm -f $ZTMP
14+
# @zinit-scheduler with "burst" argument executes all tasks "now"
15+
eval zinit load'"[[ \$TMPQ = , ]]"' atload"\"!touch \$ZTMP; TMPQ=.; TMPE=.\"" unload'"[[ \$TMPQ = . ]]"' for zdharma-continuum/null && @zinit-scheduler burst && @zinit-scheduler burst
16+
state=$?
17+
# Test if plugin effects withdrawal on unload is working
18+
assert "$TMPE" different_to .
19+
# Test if plugin is marked as unloaded
20+
assert "$ZINIT_REGISTERED_PLUGINS[-1]" different_to zdharma-continuum/null
21+
assert "$state" equals 0
22+
# Test if plugin is loaded
23+
assert "$ZTMP" is_file
24+
}
25+
26+
@test 'wait-ice-with-condition' {
27+
rm -f $ZTMP
1328
# @zinit-scheduler with "burst" argument executes all tasks "now"
14-
eval zinit wait nocd atload\'touch $ZTMP\' for zdharma-continuum/null && @zinit-scheduler burst
29+
eval zinit wait'"[[ -n $ZTMP ]]"' atload'"touch $ZTMP"' for zdharma-continuum/null && @zinit-scheduler burst
30+
state=$?
1531
assert $state equals 0
1632
assert $ZTMP is_file
1733
}
1834

35+
@test 'wait-ice' {
36+
rm -f $ZTMP
37+
# @zinit-scheduler with "burst" argument executes all tasks "now"
38+
eval zinit wait nocd atload'"touch $ZTMP"' for zdharma-continuum/null && @zinit-scheduler burst
39+
state=$?
40+
assert "$state" equals 0
41+
assert "$ZTMP" is_file
42+
}
43+
1944
# @test 'nnn' {
2045
# run zinit light-mode for jarun/nnn
2146
# zinit cd jarun/nnn

0 commit comments

Comments
 (0)