Skip to content

Commit

Permalink
Test the special wait'' syntax using a eval snippet, like e.g.: wait'…
Browse files Browse the repository at this point in the history
…[[ -n $var ]]'.

Also test plugin unloading of atload'!…' ice (tracked atload'' ice)
  • Loading branch information
psprint committed Dec 22, 2022
1 parent 1bb2d6c commit d7d007f
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions tests/plugins.zunit
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,41 @@
ZBIN=$ZPFX/bin
export LC_CTYPE=C
export LANG=C
export ZTMP=$(mktemp -qu)
export ZTMP=$(mktemp -qu) TMPQ=,
}

@test 'wait-ice' {
@test '(un)load-ices' {
rm -f $ZTMP
# @zinit-scheduler with "burst" argument executes all tasks "now"
eval zinit load'"[[ \$TMPQ = , ]]"' atload"\"!touch \$ZTMP; TMPQ=.; TMPE=.\"" unload'"[[ \$TMPQ = . ]]"' for zdharma-continuum/null && @zinit-scheduler burst && @zinit-scheduler burst
state=$?
# Test if plugin effects withdrawal on unload is working
assert "$TMPE" different_to .
# Test if plugin is marked as unloaded
assert "$ZINIT_REGISTERED_PLUGINS[-1]" different_to zdharma-continuum/null
assert "$state" equals 0
# Test if plugin is loaded
assert "$ZTMP" is_file
}

@test 'wait-ice-with-condition' {
rm -f $ZTMP
# @zinit-scheduler with "burst" argument executes all tasks "now"
eval zinit wait nocd atload\'touch $ZTMP\' for zdharma-continuum/null && @zinit-scheduler burst
eval zinit wait'"[[ -n $ZTMP ]]"' atload'"touch $ZTMP"' for zdharma-continuum/null && @zinit-scheduler burst
state=$?
assert $state equals 0
assert $ZTMP is_file
}

@test 'wait-ice' {
rm -f $ZTMP
# @zinit-scheduler with "burst" argument executes all tasks "now"
eval zinit wait nocd atload'"touch $ZTMP"' for zdharma-continuum/null && @zinit-scheduler burst
state=$?
assert "$state" equals 0
assert "$ZTMP" is_file
}

# @test 'nnn' {
# run zinit light-mode for jarun/nnn
# zinit cd jarun/nnn
Expand Down

0 comments on commit d7d007f

Please sign in to comment.