Skip to content

Commit

Permalink
Merge pull request #612 from vladdoster/fix/sbin-delete
Browse files Browse the repository at this point in the history
fix: variable scope in delete command
  • Loading branch information
vladdoster authored Dec 30, 2023
2 parents 70d63bb + 9f93790 commit 72dee44
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 59 deletions.
1 change: 0 additions & 1 deletion doc/zsdoc/zinit-autoload.zsh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ Has 111 line(s). Calls functions:
|-- .zinit-prompt
|-- .zinit-run-delete-hooks
|   `-- zinit-side.zsh/.zinit-countdown
|-- zinit-side.zsh/.zinit-compute-ice
|-- zinit.zsh/+zi-log
|-- zinit.zsh/.zinit-any-to-user-plugin
`-- zinit.zsh/zinit
Expand Down
1 change: 0 additions & 1 deletion doc/zsdoc/zinit-side.zsh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ Uses feature(s): _setopt_

Called by:

zinit-autoload.zsh/.zinit-delete
zinit-autoload.zsh/.zinit-edit
zinit-autoload.zsh/.zinit-recall
zinit-autoload.zsh/.zinit-update-or-status-snippet
Expand Down
40 changes: 22 additions & 18 deletions tests/_support/bootstrap
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#!/usr/bin/env zsh

# emulate -L zsh
# setopt no_global_rcs no_rcs no_aliases extended_glob null_glob

emulate zsh
setopt no_global_rcs no_rcs no_aliases extended_glob

Expand All @@ -20,17 +25,16 @@ if [[ ! -d ${TMP_ZUNIT} ]]; then
fi

typeset -gx zi_test_dir="${TMP_ZUNIT}"
typeset -gxAUH ZINIT
# DEBUG 'true'
typeset -gxAUH ZINIT=()
ZINIT+=(
BIN_DIR ${zi_test_dir}/zinit.git
COMPLETIONS_DIR ${zi_test_dir}/completions SNIPPETS_DIR ${zi_test_dir}/snippets
HOME_DIR ${zi_test_dir} PLUGINS_DIR ${zi_test_dir}/plugins
ZCOMPDUMP_PATH ${zi_test_dir}/zcompdump ZPFX ${zi_test_dir}/polaris
POLARIS ${zi_test_dir}/polaris
BIN_DIR "${zi_test_dir}/zinit.git"
COMPLETIONS_DIR "${zi_test_dir}/completions" SNIPPETS_DIR "${zi_test_dir}/snippets"
HOME_DIR "${zi_test_dir}" PLUGINS_DIR "${zi_test_dir}/plugins"
ZCOMPDUMP_PATH "${zi_test_dir}/zcompdump" ZPFX "${zi_test_dir}/polaris"
POLARIS "${zi_test_dir}/polaris"
)
typeset -gxH ZPFX=
ZPFX="$zi_test_dir"/polaris
ZPFX="${zi_test_dir}/polaris"

command git diff > ${ZINIT[HOME_DIR]}/unstaged.diff
# info 'creating test env'
Expand All @@ -49,23 +53,24 @@ fi

if [[ -s $ZINIT[HOME_DIR]/unstaged.diff ]]; then
(
git -C $ZINIT[BIN_DIR] apply $ZINIT[HOME_DIR]/unstaged.diff && \
git -C "${ZINIT[BIN_DIR]}" apply "${ZINIT[HOME_DIR]}/unstaged.diff" && \
chmod g-rwX "${ZINIT[HOME_DIR]}" && \
zcompile "${ZINIT[BIN_DIR]}/zinit.zsh" >/dev/null
) >/dev/null
fi
(( $? != 0 )) && { error "Unable to copy ${GIT_REPO} to ${TMP_ZUNIT}" >&2; exit 1 }

hash -f
builtin hash -d zinit=$zi_test_dir
builtin hash -d zpfx=$zi_test_dir/polaris
builtin hash -d plugins=$zi_test_dir/plugins
source $zi_test_dir/zinit.git/zinit.zsh
builtin hash -d zinit="${zi_test_dir}"
builtin hash -d zpfx="${zi_test_dir}/polaris"
builtin hash -d plugins="${zi_test_dir}/plugins"
source "${zi_test_dir}/zinit.git/zinit.zsh"
(( $? != 0 )) && { error "Unable to source zinit" >&2; exit 1 }
hash -f
builtin hash -d zinit=$zi_test_dir
builtin hash -d zpfx=$zi_test_dir/polaris
builtin hash -d plugins=$zi_test_dir/plugins
builtin hash -d zinit="${zi_test_dir}"
builtin hash -d zpfx="${zi_test_dir}/polaris"
builtin hash -d plugins="${zi_test_dir}/plugins"

{
zinit for \
@zdharma-continuum/zinit-annex-bin-gem-node \
Expand All @@ -74,5 +79,4 @@ builtin hash -d plugins=$zi_test_dir/plugins
@zdharma-continuum/zinit-annex-linkman
}>/dev/null

+zi-log "{m} loaded $annex dependencies"
zinit zstatus
zinit zstatus
97 changes: 58 additions & 39 deletions tests/gh-r.zunit
Original file line number Diff line number Diff line change
@@ -1,38 +1,13 @@
#!/usr/bin/env zunit

@setup {
load "${PWD}/tests/_support/annex_test_assertions"
HOME="$zi_test_dir" # Stops programs creating directories in user home
typeset -gx ZBIN="$zi_test_dir/polaris/bin" os_type="${OSTYPE//[0-9\.]*/}"
[[ ! -d $ZBIN ]] && mkdir -p "$ZBIN"
zinit default-ice --quiet from'gh-r' lbin'!' null
load "${PWD}/tests/_support/annex_test_assertions"
HOME="$zi_test_dir" # Stops programs creating directories in user home
typeset -gx ZBIN="$zi_test_dir/polaris/bin" os_type="${OSTYPE//[0-9\.]*/}"
[[ ! -d $ZBIN ]] && mkdir -p "$ZBIN"
zinit default-ice --quiet from'gh-r' lbin'!' null
}

# @test 'atmos' { Universal Tool for DevOps and Cloud Automation (works with terraform, helm, helmfile, etc)
# skip 'null'
# run zinit for lbin'!* -> atmos' @cloudposse/atmos; assert $state equals 0
# local atmos="$ZBIN/atmos"; assert "$atmos" is_executable
# $atmos version; assert $state equals 0
# }
# @test 'bit' { A tool for composable software development
# skip 'skip bit test due to gh-r version bug'
# run zinit lbin'!bit* -> bit' for @teambit/bit; assert $state equals 0
# local bit="$ZBIN/bit"; assert "$bit" is_executable
# $bit --version; assert $state equals 0
# }
# @test 'neovim::appimage' { # Vim-fork focused on extensibility and usability
# skip 'null'
# run zinit bpick'*appimage*' id-as'neovim/appimage' for neovim/neovim
# assert $state equals 0; assert $output contains 'nvim.appimage'
# assert "$ZINIT[PLUGINS_DIR]/neovim---appimage/nvim.appimage" is_file
# }
# @test 'neovim::binary' { # Vim-fork focused on extensibility and usability
# skip 'null'
# run zinit lbin'!**/nvim' id-as'neovim/binary' for neovim/neovim; assert $state equals 0; assert $output does_not_contain 'appimage'
# local nvim="$ZBIN/nvim"; assert "$nvim" is_executable
# $nvim --version; assert $state equals 0
# }

@test 'act' { # Run your GitHub Actions locally
run zinit for @nektos/act; assert $state equals 0
local act="$ZBIN/act"; assert "$act" is_executable
Expand Down Expand Up @@ -575,22 +550,38 @@
run "$mdbook" --version;
assert $state equals 127; assert $output contains 'no such file or directory'
}
@test 'mdbook-lbin' { # Create book from markdown files. Like Gitbook but implemented in Rust
run zinit for @rust-lang/mdBook; assert $state equals 0
local mdbook="$ZBIN/mdbook"; assert "$mdbook" is_executable
run "$mdbook" --version; assert $state equals 0
run file "$mdbook"; assert $output contains 'executable'
zinit delete --yes rust-lang/mdBook;
run "$mdbook" --version; assert $state equals 127; assert $output contains 'no such file or directory'
}
@test 'mdbook-sbin' { # Create book from markdown files. Like Gitbook but implemented in Rust
load_bin_gem_node
local mdbook="$ZBIN/mdbook";
run zinit from'gh-r' sbin"mdbook" for @rust-lang/mdBook; assert $state equals 0
local mdbook="$ZBIN/mdbook"; assert "$mdbook" is_executable
run "$mdbook" --version; assert $state equals 0
run file "$mdbook"; assert $output contains 'zsh script'; assert $output contains 'ASCII text'
zinit delete --yes rust-lang/mdBook; assert $state equals 0
run "$mdbook" --version; assert $state equals 127; assert $output contains 'no such file or directory'
# @test 'mdbook-sbin' { # Create book from markdown files. Like Gitbook but implemented in Rust
# load_bin_gem_node
# local mdbook="$ZBIN/mdbook";

run zinit from'gh-r' sbin"mdbook" for @rust-lang/mdBook; assert $state equals 0 assert "$mdbook" is_executable
# run zinit from'gh-r' sbin"mdbook" for @rust-lang/mdBook; assert $state equals 0 assert "$mdbook" is_executable

run "$mdbook" --version; assert $state equals 0
# run "$mdbook" --version; assert $state equals 0

run command file "$(command realpath ${mdbook})";
assert $output contains 'zsh script'; assert $output contains 'ASCII text'
# run command file "$(command realpath ${mdbook})";
# assert $output contains 'zsh script'; assert $output contains 'ASCII text'

run zinit delete --yes rust-lang/mdBook; assert $state equals 0
# run zinit delete --yes rust-lang/mdBook; assert $state equals 0

run "$mdbook" --version;
assert $state equals 127; assert $output contains 'no such file or directory'
}
# run "$mdbook" --version;
# assert $state equals 127; assert $output contains 'no such file or directory'
# }
@test 'mdcat' { # cat for markdown
run zinit for @swsnr/mdcat; assert $state equals 0
local mdcat="$ZBIN/mdcat"; assert "$mdcat" is_executable
Expand Down Expand Up @@ -885,4 +876,32 @@
run $zoxide --version; assert $state equals 0
}

#=============
# Flaky Tests
#=============
# @test 'atmos' { Universal Tool for DevOps and Cloud Automation (works with terraform, helm, helmfile, etc)
# skip 'null'
# run zinit for lbin'!* -> atmos' @cloudposse/atmos; assert $state equals 0
# local atmos="$ZBIN/atmos"; assert "$atmos" is_executable
# $atmos version; assert $state equals 0
# }
# @test 'bit' { A tool for composable software development
# skip 'skip bit test due to gh-r version bug'
# run zinit lbin'!bit* -> bit' for @teambit/bit; assert $state equals 0
# local bit="$ZBIN/bit"; assert "$bit" is_executable
# $bit --version; assert $state equals 0
# }
# @test 'neovim::appimage' { # Vim-fork focused on extensibility and usability
# skip 'null'
# run zinit bpick'*appimage*' id-as'neovim/appimage' for neovim/neovim
# assert $state equals 0; assert $output contains 'nvim.appimage'
# assert "$ZINIT[PLUGINS_DIR]/neovim---appimage/nvim.appimage" is_file
# }
# @test 'neovim::binary' { # Vim-fork focused on extensibility and usability
# skip 'null'
# run zinit lbin'!**/nvim' id-as'neovim/binary' for neovim/neovim; assert $state equals 0; assert $output does_not_contain 'appimage'
# local nvim="$ZBIN/nvim"; assert "$nvim" is_executable
# $nvim --version; assert $state equals 0
# }

# vim:ft=zsh:sw=2:sts=2:et:foldmarker={,}:foldmethod=marker

0 comments on commit 72dee44

Please sign in to comment.