Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing wait ice and plugin effects unloading #442

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 55 additions & 21 deletions tests/plugins.zunit
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
#!/usr/bin/env zunit

@setup {
HOME="$zi_test_dir"
HOME="$zi_test_dir" TMPQ=,
typeset -gx ZBIN="$zi_test_dir/polaris/bin"
zinit default-ice as'null' light-mode nocompile nocompletions
ZBIN=$ZPFX/bin
export LC_CTYPE=C; export LANG=C
export ZTMP=$(mktemp -qu)
}

@test '(un)load-ices' {
rm -f $ZTMP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved to the setup function.

# @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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved to the setup function.

# @zinit-scheduler with "burst" argument executes all tasks "now"
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved to the setup function.

# @zinit-scheduler with "burst" argument executes all tasks "now"
eval zinit wait nocd atload'"touch $ZTMP"' for zdharma-continuum/null && @zinit-scheduler burst
psprint marked this conversation as resolved.
Show resolved Hide resolved
state=$?
assert "$state" equals 0
assert "$ZTMP" is_file
}

# @test 'cmatrix' {
# run zinit build for @abishekvashok/cmatrix;
# local cmatrix="$ZBIN/cmatrix"; assert "$cmatrix" is_executable
# run "$cmatrix" -V; assert $state equals 0
# # ensure cmake artifacts are deleted
# zinit delete --yes abishekvashok/cmatrix; assert $state equals 0
# run "$cmatrix"; assert $state equals 127
# }
@test 'figlet' {
run zinit make for @cmatsuoka/figlet; assert $state equals 0
local figlet="$ZBIN/figlet"; assert "$figlet" is_executable
Expand Down Expand Up @@ -69,18 +95,6 @@
run zinit delete --yes neovim/neovim; assert $state equals 0
run "$neovim" --version; assert $state equals 127
}
# @test 'neovim-cmake' {
# run zinit cmake for @neovim/neovim; assert $state equals 0
# local neovim="$ZBIN/nvim"; assert $neovim is_executable
# run "$neovim" --version; assert $state equals 0
#
# nvim_ver="$($neovim --version | head -n1 | awk '{print $2}')";
# nvim_commit="$(git --work-tree=$ZINIT[PLUGINS_DIR]/neovim---neovim rev-parse --short HEAD)";
# print -lPr " " "nvim ver: %F{blue}$nvim_ver%f" "nvim commit sha: %F{blue}$nvim_commit%f" "check: [[ %F{blue}$nvim_ver%f = %F{blue}*$nvim_commit(#e)%f ]]"
# [[ $nvim_ver = *$nvim_commit(#e) ]] && print -P "%F{green}ok%f"
#
# run zinit delete --yes neovim/neovim; assert $state equals 0
# }
@test 'tmux' {
if [[ $OSTYPE =~ 'darwin*' ]]; then
run zinit configure'--disable-utf8proc' make for @tmux/tmux; assert $state equals 0
Expand Down Expand Up @@ -110,6 +124,26 @@
# ===========
# Flaky tests
# ===========
# @test 'cmatrix' {
# run zinit build for @abishekvashok/cmatrix;
# local cmatrix="$ZBIN/cmatrix"; assert "$cmatrix" is_executable
# run "$cmatrix" -V; assert $state equals 0
# # ensure cmake artifacts are deleted
# zinit delete --yes abishekvashok/cmatrix; assert $state equals 0
# run "$cmatrix"; assert $state equals 127
# }
# @test 'neovim-cmake' {
# run zinit cmake for @neovim/neovim; assert $state equals 0
# local neovim="$ZBIN/nvim"; assert $neovim is_executable
# run "$neovim" --version; assert $state equals 0
#
# nvim_ver="$($neovim --version | head -n1 | awk '{print $2}')";
# nvim_commit="$(git --work-tree=$ZINIT[PLUGINS_DIR]/neovim---neovim rev-parse --short HEAD)";
# print -lPr " " "nvim ver: %F{blue}$nvim_ver%f" "nvim commit sha: %F{blue}$nvim_commit%f" "check: [[ %F{blue}$nvim_ver%f = %F{blue}*$nvim_commit(#e)%f ]]"
# [[ $nvim_ver = *$nvim_commit(#e) ]] && print -P "%F{green}ok%f"
#
# run zinit delete --yes neovim/neovim; assert $state equals 0
# }
# @test 'stow' {
# run zinit configure'--without-pmdir' make for @aspiers/stow; assert $state equals 0
# local stow="$ZBIN/stow"; assert "$stow" is_executable
Expand Down
Loading