Skip to content

Commit

Permalink
fix: failing zunit tests & bootstrap script
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
  • Loading branch information
vladdoster committed Jan 5, 2023
1 parent 515688b commit d618467
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 183 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['macos-12','ubuntu-20.04','ubuntu-22.04']
os: ['macos-latest','ubuntu-latest']
fail-fast: false

steps:
Expand All @@ -44,18 +44,17 @@ jobs:
- name: "install musl"
if: runner.os == 'Linux'
run: |
sudo apt-get clean && sudo apt-get update && sudo apt-get install \
sudo apt-get update \
&& sudo apt-get install \
build-essential curl file gcc gcc-multilib glibc-source \
libc6 libc6-dev \
musl musl-dev musl-tools unzip zsh
- name: "install dependencies"
id: install-deps
run: brew install ncurses svn unzip zsh xz

- name: "install revolver"
id: install-revolver
run: brew install molovo/revolver/revolver
run: |
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
brew install --force --overwrite gnu-sed coreutils unzip xz zsh
- name: "install zunit"
id: install-zunit
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ test/
txt/
zmodules/
tests/_output/
tests/_support/zunit/
tests/_support/tmp*
.idea
6 changes: 3 additions & 3 deletions .zunit.yml
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
11 changes: 6 additions & 5 deletions tests/_support/annex_test_assertions
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
}
86 changes: 52 additions & 34 deletions tests/_support/bootstrap
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
48 changes: 13 additions & 35 deletions tests/annexes.zunit
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

0 comments on commit d618467

Please sign in to comment.