-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: failing zunit tests & bootstrap script
Signed-off-by: Vladislav Doster <[email protected]>
- Loading branch information
1 parent
515688b
commit d618467
Showing
8 changed files
with
160 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,5 +20,5 @@ test/ | |
txt/ | ||
zmodules/ | ||
tests/_output/ | ||
tests/_support/zunit/ | ||
tests/_support/tmp* | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
allow_risky: false | ||
directories: | ||
tests: tests | ||
output: tests/_output | ||
support: tests/_support | ||
fail_fast: true | ||
verbose: true | ||
tests: tests | ||
fail_fast: false | ||
verbose: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
#!/usr/bin/env zsh | ||
|
||
_annex_test_function() { | ||
run zinit load zdharma-continuum/${1} | ||
is_annex() { | ||
local annex="zinit-annex-${1}" | ||
run zinit load zdharma-continuum/${annex} | ||
assert ${state} equals 0 | ||
zinit cd zdharma-continuum/${1} | ||
assert ${PWD}/${${1}//zinit-annex/z-a}.plugin.zsh is_file | ||
assert ${PWD}/${${1}//zinit-annex/z-a}.plugin.zsh is_readable | ||
zinit cd zdharma-continuum/${annex} | ||
assert ${PWD}/${${annex}//zinit-annex/z-a}.plugin.zsh is_file | ||
assert ${PWD}/${${annex}//zinit-annex/z-a}.plugin.zsh is_readable | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,67 @@ | ||
#!/usr/bin/env zsh | ||
setopt NO_GLOBAL_RCS NO_GLOBAL_EXPORT NO_RCS | ||
|
||
# Log functions [[[ | ||
function error(){ print -P "%F{red}ZUNIT[ERROR]: $1%f" && return 1; } | ||
function info() { print -P "%F{blue}ZUNIT[INFO]%f: %F{cyan}$1%f"; } | ||
function warn() { print -P "%F{yellow}ZUNIT[WARN]: $1%f"; } | ||
function error(){ print -P "%F{red}[ERROR]%f: ${1}" && return 1; } | ||
function info() { print -P "%F{green}[INFO]%f:%F{cyan} ${1} %f"; } | ||
function warn() { print -P "%F{yellow}[WARN]%f: ${1}"; } | ||
# ]]] | ||
# Create Zunit test environment [[[ | ||
GIT_REPO=$(git rev-parse --show-toplevel) | ||
typeset -gAH ZINIT; | ||
ZINIT[HOME_DIR]="$GIT_REPO/tests/_support/zunit"; ZINIT[BIN_DIR]=$ZINIT[HOME_DIR]/zinit.git; | ||
ZINIT[COMPLETIONS_DIR]=$ZINIT[HOME_DIR]/completions; ZINIT[SNIPPETS_DIR]=$ZINIT[HOME_DIR]/snippets; | ||
ZINIT[ZCOMPDUMP_PATH]=$ZINIT[HOME_DIR]/zcompdump; ZINIT[PLUGINS_DIR]=$ZINIT[HOME_DIR]/plugins; | ||
|
||
_mktemp_cmd='mktemp' | ||
if (( ${+commands[gmktemp]} )); then | ||
_mktemp_cmd='gmktemp' | ||
fi | ||
TMP_ZUNIT=$(${_mktemp_cmd} --directory --tmpdir="${GIT_REPO}/tests/_support") | ||
if [[ ! -d ${TMP_ZUNIT} ]]; then | ||
error "zunit temp dir not found" | ||
exit 1 | ||
fi | ||
|
||
typeset -gAH ZINIT; | ||
ZINIT[HOME_DIR]=${TMP_ZUNIT}; | ||
ZINIT[BIN_DIR]=$ZINIT[HOME_DIR]/zinit.git; | ||
ZINIT[COMPLETIONS_DIR]=$ZINIT[HOME_DIR]/completions; | ||
ZINIT[PLUGINS_DIR]=$ZINIT[HOME_DIR]/plugins; | ||
ZINIT[SNIPPETS_DIR]=$ZINIT[HOME_DIR]/snippets; | ||
ZINIT[ZCOMPDUMP_PATH]=$ZINIT[HOME_DIR]/zcompdump; | ||
ZPFX=$ZINIT[HOME_DIR]/polaris; | ||
|
||
rm -rf $ZINIT[HOME_DIR] | ||
mkdir -p $ZINIT[HOME_DIR] | ||
git diff > $ZINIT[HOME_DIR]/unstaged.diff | ||
info 'creating test env' \ | ||
&& git clone \ | ||
--dissociate \ | ||
--local \ | ||
--no-hardlinks \ | ||
--reference "$GIT_REPO" \ | ||
"$GIT_REPO" \ | ||
"$GIT_REPO"/tests/_support/zunit/zinit.git \ | ||
|| error 'failed to create zinit copy for test env' \ | ||
&& [[ -s $ZINIT[HOME_DIR]/unstaged.diff ]] \ | ||
&& git -C $ZINIT[BIN_DIR] apply $ZINIT[HOME_DIR]/unstaged.diff \ | ||
&& info 'installing zinit' \ | ||
&& command chmod g-rwX $ZINIT[HOME_DIR] \ | ||
&& zcompile $ZINIT[BIN_DIR]/zinit.zsh \ | ||
&& info 'successfully created zunit env' \ | ||
|| error 'failed to create zunit env' | ||
command git diff > ${ZINIT[HOME_DIR]}/unstaged.diff | ||
info 'creating test env' | ||
git clone \ | ||
--dissociate \ | ||
--local \ | ||
--no-hardlinks \ | ||
--reference "${GIT_REPO}" \ | ||
"${GIT_REPO}" \ | ||
"${ZINIT[BIN_DIR]}" | ||
if (( $? != 0 )); then | ||
error "Unable to copy ${GIT_REPO} to ${TMP_ZUNIT}" >&2 | ||
exit 1 | ||
fi | ||
|
||
if [[ -s $ZINIT[HOME_DIR]/unstaged.diff ]]; then | ||
( | ||
git -C $ZINIT[BIN_DIR] apply $ZINIT[HOME_DIR]/unstaged.diff && \ | ||
chmod g-rwX "${ZINIT[HOME_DIR]}" && \ | ||
zcompile "${ZINIT[BIN_DIR]}/zinit.zsh" | ||
) | ||
fi | ||
(( $? != 0 )) && { error "Unable to copy ${GIT_REPO} to ${TMP_ZUNIT}" >&2; exit 1 } | ||
|
||
source $ZINIT[BIN_DIR]/zinit.zsh \ | ||
&& autoload -Uz _zinit \ | ||
&& (( ${+_comps} )) \ | ||
&& _comps[zinit]=_zinit | ||
{ | ||
source $ZINIT[BIN_DIR]/zinit.zsh && \ | ||
autoload -Uz _zinit && \ | ||
(( ${+_comps} )) && \ | ||
_comps[zinit]=_zinit | ||
} | ||
(( $? != 0 )) && { error "Unable to copy ${GIT_REPO} to ${TMP_ZUNIT}" >&2; exit 1 } | ||
# ]]] | ||
# Install Annexes [[[ | ||
info 'installing test dependencies' | ||
# ver'fix/improve-lbin-logic' \ | ||
zinit depth'1' light-mode for \ | ||
zdharma-continuum/zinit-annex-binary-symlink \ | ||
zdharma-continuum/zinit-annex-{'bin-gem-node','default-ice'} | ||
zinit depth'1' light-mode for zdharma-continuum/zinit-annex-{'binary-symlink','default-ice'} | ||
# ]]] | ||
|
||
# vim:ft=zsh:sw=2:sts=2:et:foldmarker=[[[,]]]:foldmethod=marker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,41 @@ | ||
#!/usr/bin/env zunit | ||
|
||
@setup { | ||
load $PWD/tests/_support/annex_test_assertions | ||
load "${PWD}/tests/_support/annex_test_assertions" | ||
} | ||
|
||
# TEST: zinit-annex-bin-gem-node | ||
@test 'zinit-annex-bin-gem-node' { | ||
local annex="zinit-annex-bin-gem-node" | ||
_annex_test_function $annex | ||
is_annex "bin-gem-node" | ||
} | ||
# TEST: zinit-annex-binary-symlink | ||
@test 'zinit-annex-binary-symlink' { | ||
local annex="zinit-annex-binary-symlink" | ||
_annex_test_function $annex | ||
is_annex "binary-symlink" | ||
} | ||
# TEST: zinit-annex-man | ||
@test 'zinit-annex-man' { | ||
local annex="zinit-annex-man" | ||
_annex_test_function $annex | ||
is_annex "man" | ||
} | ||
# TEST: zinit-annex-meta-plugins | ||
@test 'zinit-annex-meta-plugins' { | ||
local annex="zinit-annex-test" | ||
_annex_test_function $annex | ||
is_annex "meta-plugins" | ||
} | ||
# TEST: zinit-annex-patch-dl | ||
@test 'zinit-annex-patch-dl' { | ||
local annex="zinit-annex-patch-dl" | ||
_annex_test_function $annex | ||
is_annex "patch-dl" | ||
} | ||
# TEST: zinit-annex-pull | ||
@test 'zinit-annex-pull' { | ||
local annex="zinit-annex-pull" | ||
_annex_test_function $annex | ||
is_annex 'pull' | ||
} | ||
# TEST: zinit-annex-readurl | ||
@test 'zinit-annex-readurl' { | ||
local annex="zinit-annex-readurl" | ||
_annex_test_function $annex | ||
is_annex 'readurl' | ||
} | ||
# TEST: zinit-annex-rust | ||
@test 'zinit-annex-rust' { | ||
local annex="zinit-annex-rust" | ||
_annex_test_function $annex | ||
is_annex 'rust' | ||
} | ||
# TEST: zinit-annex-submods | ||
@test 'zinit-annex-submods' { | ||
local annex="zinit-annex-submods" | ||
_annex_test_function $annex | ||
is_annex 'submods' | ||
} | ||
# TEST: zinit-annex-test | ||
@test 'zinit-annex-test' { | ||
local annex="zinit-annex-test" | ||
_annex_test_function $annex | ||
is_annex 'test' | ||
} | ||
# TEST: zinit-annex-unscope | ||
@test 'zinit-annex-unscope' { | ||
local annex="zinit-annex-test" | ||
_annex_test_function $annex | ||
is_annex 'unscope' | ||
} | ||
|
||
# vim:ft=zsh:sw=2:sts=2:et:foldmarker=TEST,}:foldmethod=marker | ||
# vim:ft=zsh:sw=2:sts=2:et:foldmarker={,}:foldmethod=marker |
Oops, something went wrong.