Skip to content

Commit

Permalink
feat(zunit): compile command tests
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Doster <[email protected]>
  • Loading branch information
vladdoster committed Jan 19, 2024
1 parent ea3eac2 commit a7cd2a2
Showing 1 changed file with 36 additions and 19 deletions.
55 changes: 36 additions & 19 deletions tests/commands.zunit
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#!/usr/bin/env zunit
#
# zdharma-continuum/zinit/tests/commands.zunit
# Copyright (c) 2016-2021 Sebastian Gniazdowski
# Copyright (c) 2021-2023 zdharma-continuum
# Homepage: https://github.com/zdharma-continuum/zinit
# License: MIT License
#

@setup {
ZBIN="${ZPFX}/bin"
typeset -gx HOME="$zi_test_dir"
typeset -gx ZBIN="$zi_test_dir/polaris/bin"
}

@test 'help' {
for cmd in 'help' '-h' '--help'; do
run zinit $cmd
assert $output contains '—— help – usage information'
assert $state equals 0
done
run zinit -help
assert $output contains 'Unknown subcommand'
assert $state equals 1
}

@test 'delete --help' {
Expand All @@ -31,9 +36,10 @@
assert $state equals 0
}
@test 'delete a program' {
run zinit as'program' cp'wd.sh->wd' mv'_wd.sh->_wd' pick'wd' for @'mfaerevaag/wd'
run zinit delete --yes mfaerevaag/wd
run zinit as'program' cp'wd.sh->wd' mv'_wd.sh->_wd' pick'wd' completions for @'mfaerevaag/wd'
assert $state equals 0
run (( ${+commands[wd]} )); assert $state equals 0
run zinit delete --yes mfaerevaag/wd
}

@test 'plugins' {
Expand All @@ -48,16 +54,25 @@
assert $output contains "==> 4 Plugins matching 'zdharma'"
}

@test 'help' {
for cmd in 'help' '-h' '--help'; do
run zinit $cmd
assert $output contains '—— help – usage information'
assert $state equals 0
done
run zinit -help
assert $output contains 'Unknown subcommand'
assert $state equals 1
@test 'compile' {
run zinit light @zdharma-continuum/history-search-multi-word
run perl -pe 's/\x1b\[[0-9;]*[mG]//g' <(zinit compile zdharma-continuum/history-search-multi-word)
assert $state equals 0
assert $output contains "==> Compiling history-search-multi-word.plugin.zsh [OK]"
}
@test 'compile multiple files' {
run zinit for compile'h*~*zwc' id-as'hsmw-compile-ice' @zdharma-continuum/history-search-multi-word
run perl -pe 's/\x1b\[[0-9;]*[mG]//g' <(zinit compile hsmw-compile-ice)
assert $output contains "==> Compiling 4 files history-search-multi-word, history-search-multi-word.plugin.zsh, hsmw-context-main, hsmw-highlight [OK]"
assert $state equals 0
}
@test 'compile single file' {
run zinit for id-as'hsmw-no-compile-ice' @zdharma-continuum/history-search-multi-word
run perl -pe 's/\x1b\[[0-9;]*[mG]//g' <(zinit compile hsmw-no-compile-ice)
assert $state equals 0
assert $output contains "==> Compiling history-search-multi-word.plugin.zsh [OK]"
}

@test 'self-update' {
run zinit self-update
assert $output contains 'Already up-to-date.'
Expand All @@ -73,3 +88,5 @@
run +zi-log -n '{m} message'
assert $output contains 'message'; assert $state equals 0
}

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

0 comments on commit a7cd2a2

Please sign in to comment.