Skip to content

Commit

Permalink
Merge branch 'refactor/make-ices' into fix/sbin-delete
Browse files Browse the repository at this point in the history
  • Loading branch information
vladdoster authored Dec 30, 2023
2 parents c729df3 + 70d63bb commit 9f93790
Show file tree
Hide file tree
Showing 9 changed files with 513 additions and 414 deletions.
75 changes: 47 additions & 28 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Unit tests
name: Unit Tests

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
TERM: xterm-256color

on:
Expand Down Expand Up @@ -39,40 +40,58 @@ jobs:
id: setup-homebrew
uses: Homebrew/actions/setup-homebrew@master

# - name: "install musl"
# if: runner.os == 'Linux'
# run: sudo apt-get install build-essential curl file gcc gcc-multilib glibc-source libc6 libc6-dev unzip xz-utils zsh
- name: "install musl"
if: runner.os == 'Linux'
run: |
sudo apt-get update --yes
sudo apt-get install --no-install-recommends --yes \
autoconf automake autotools-dev \
build-essential byacc\
file \
gcc gettext glibc-source grep \
libc6 libc6-dev libevent-dev libncurses5-dev libncursesw5-dev libtool libuvc0 lua5.1 \
m4 \
ninja-build \
pkg-config \
xz-utils
- name: "install dependencies"
id: install-deps
run: |
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
brew install --force --overwrite gnu-sed coreutils unzip xz zsh
brew install --force --overwrite autoconf automake binutils byacc cmake coreutils curl gettext gnu-sed libevent libtool libuv lua [email protected] make ncurses ninja parallel pkg-config texinfo unzip xz zsh
brew link --force --overwrite ncurses
- name: "install zunit"
id: install-zunit
run: |
mkdir -p "$HOME/.local/bin" && echo "$HOME/.local/bin" >> $GITHUB_PATH
git clone --depth 1 https://github.com/zdharma-continuum/zunit; cd ./zunit
zsh -c -l './build.zsh' && sudo chmod u+x ./zunit && cp ./zunit "$HOME/.local/bin/"
# - name: disable secssessment system policy security
# run: sudo spctl --master-disable

- name: "annexes"
run: zunit run tests/annexes.zunit

- name: "commands"
run: zunit run tests/commands.zunit

- name: "gh-r"
run: zunit run --fail-fast --verbose tests/gh-r.zunit

- name: "ices"
run: zunit run tests/ices.zunit

- name: "plugins"
run: zunit run tests/plugins.zunit

- name: "snippets"
run: zunit run tests/snippets.zunit
zsh -l -c './build.zsh' && sudo chmod u+x ./zunit && cp ./zunit "$HOME/.local/bin/"
- name: Run tests
shell: zsh {0}
run: |
command -p ls -1 ./tests/*zunit \
| parallel \
--jobs=0 \
--keep-order \
--line-buffer \
$HOME/.local/bin/zunit run
# - name: "annexes"
# run: zunit run tests/annexes.zunit

# - name: "commands"
# run: zunit run tests/commands.zunit

# - name: "gh-r"
# run: zunit run --fail-fast --verbose tests/gh-r.zunit

# - name: "ices"
# run: zunit run tests/ices.zunit

# - name: "plugins"
# run: zunit run tests/plugins.zunit

# - name: "snippets"
# run: zunit run tests/snippets.zunit
61 changes: 30 additions & 31 deletions tests/_support/bootstrap
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
emulate -L zsh
setopt no_global_rcs no_rcs no_aliases extended_glob null_glob
#!/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

# Log functions [[[
function error(){ print -P "%F{red}[ERROR]%f: ${1}" && return 1; }
Expand All @@ -20,19 +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
# FORK 'vladdoster' REPO 'zinit-t'
# typeset -gxAUH ZINIT=(${(kv)CONFIG})
ZPFX="${zi_test_dir}/polaris"

command git diff > ${ZINIT[HOME_DIR]}/unstaged.diff
# info 'creating test env'
Expand All @@ -51,33 +53,30 @@ 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
# ]]]
# Install Annexes [[[
# +zi-log '{m} installing test dependencies'
zinit for \
@zdharma-continuum/zinit-annex-linkman \
@zdharma-continuum/zinit-annex-default-ice \
@zdharma-continuum/zinit-annex-binary-symlink \
@zdharma-continuum/zinit-annex-bin-gem-node
builtin hash -d zinit="${zi_test_dir}"
builtin hash -d zpfx="${zi_test_dir}/polaris"
builtin hash -d plugins="${zi_test_dir}/plugins"

+zi-log "{m} loaded $annex dependencies"
# ]]]
zinit zstatus
{
zinit for \
@zdharma-continuum/zinit-annex-bin-gem-node \
@zdharma-continuum/zinit-annex-binary-symlink \
@zdharma-continuum/zinit-annex-default-ice \
@zdharma-continuum/zinit-annex-linkman
}>/dev/null

zinit zstatus
14 changes: 11 additions & 3 deletions tests/commands.zunit
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,20 @@
done
run zinit -help
assert $output contains 'Unknown subcommand'
assert $state equals 1
assert $state equals 1
}
@test 'self-update' {
run zinit self-update
assert $output contains 'Already up-to-date.'
assert $state equals 0
}

# vim:ft=zsh:sw=2:sts=2:et:foldmarker={,}:foldmethod=marker
@test 'set-debug' {
ZINIT+=(DEBUG 'true')
run +zi-log -n '{dbg} message'
assert $output contains '[debug]'; assert $state equals 0
}
@test 'unset-dbg' {
run +zi-log -n '{dbg} message'; assert $output contains ''
run +zi-log -n '{m} message'
assert $output contains 'message'; assert $state equals 0
}
122 changes: 80 additions & 42 deletions tests/gh-r.zunit
Original file line number Diff line number Diff line change
@@ -1,45 +1,17 @@
#!/usr/bin/env zunit




@setup {
HOME="$ZPFX" # Stops programs creating directories in user home
export ZBIN="${ZPFX}/bin"
export os_type="${OSTYPE//[0-9\.]*/}"
load "${PWD}/tests/_support/annex_test_assertions"
zinit default-ice --quiet from'gh-r' lbin
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
$act --version; assert $state equals 0
run "$act" --version; assert $state equals 0
}
@test 'akamai' { # Manage and configure Akamai from the Command Line.
run zinit id-as'akamai' lbin'akamai*->akamai' for @akamai/cli; assert $state equals 0
Expand Down Expand Up @@ -81,7 +53,7 @@
[[ $OSTYPE =~ 'darwin*' ]] && skip "on $os_type"
run zinit for @imsnif/bandwhich; assert $state equals 0
local bandwhich="$ZBIN/bandwhich"; assert "$bandwhich" is_executable
run $bandwhich --help; assert $state equals 0
run "$bandwhich" --version; assert $state equals 0
}
@test 'bat' { # A cat(1) clone with wings
run zinit for @sharkdp/bat; assert $state equals 0
Expand Down Expand Up @@ -476,12 +448,12 @@
local just="$ZBIN/just"; assert "$just" is_executable
run $just --version; assert $state equals 0
}
@test 'keepassxc' { # a cross-platform community-driven port of the Windows application Keepass Password Safe
[[ $OSTYPE =~ 'linux*' ]] && skip "skipped on $os_type"
run zinit for lbin'!*-cli -> keepassxc-cli' @keepassxreboot/keepassxc; assert $state equals 0
local keepassxc="$ZBIN/keepassxc-cli"; assert "$keepassxc" is_executable
run $keepassxc --version; assert $state equals 0
}
# @test 'keepassxc' { # a cross-platform community-driven port of the Windows application Keepass Password Safe
# [[ $OSTYPE =~ 'linux*' ]] && skip "skipped on $os_type"
# run zinit for lbin'!*-cli -> keepassxc-cli' @keepassxreboot/keepassxc; assert $state equals 0
# local keepassxc="$ZBIN/keepassxc-cli"; assert "$keepassxc" is_executable
# run $keepassxc --version; assert $state equals 0
# }
@test 'ko' { # Build and deploy Go applications on Kubernetes
run zinit for @ko-build/ko; assert $state equals 0
local ko="$ZBIN/ko"; assert "$ko" is_executable
Expand All @@ -502,6 +474,16 @@
local cli="$ZBIN/kubedb"; assert "$cli" is_executable
run "$cli" version; assert $state equals 0
}
@test 'kubectl-plugins' { # Faster way to switch between clusters and namespaces in kubectl
[[ $OSTYPE =~ 'darwin*' ]] && skip "skipped on $os_type"
load_bin_gem_node
run zinit for bpick'kubectx;kubens' sbin'kubectx;kubens' @ahmetb/kubectx
local bin prog
for bin in 'kubectx' 'kubens'; do
prog="$ZBIN/${bin}"; assert "$prog" is_executable;
run "$prog" --help; assert $state equals 0
done
}
@test 'lazygit' { # simple terminal UI for git commands
run zinit for @jesseduffield/lazygit; assert $state equals 0
local lazygit="$ZBIN/lazygit"; assert "$lazygit" is_executable
Expand Down Expand Up @@ -553,7 +535,20 @@
@test 'mcfly' { # Fly through your shell history. Great Scott
run zinit ver'v0.8.3' for @cantino/mcfly; assert $state equals 0
local mcfly="$ZBIN/mcfly"; assert "$mcfly" is_executable
run $mcfly --version; assert $state equals 0
run "$mcfly" --version; assert $state equals 0
}
@test 'mdbook-lbin' { # Create book from markdown files. Like Gitbook but implemented in Rust
local mdbook="$ZBIN/mdbook";
run zinit for @rust-lang/mdBook; assert $state equals 0 assert "$mdbook" is_executable

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

run command file "$(command realpath ${mdbook})"; assert $output contains 'executable'

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'
}
@test 'mdbook-lbin' { # Create book from markdown files. Like Gitbook but implemented in Rust
run zinit for @rust-lang/mdBook; assert $state equals 0
Expand All @@ -571,7 +566,22 @@
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 "$mdbook" --version; assert $state equals 0

# 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 "$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 @@ -866,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
2 changes: 1 addition & 1 deletion tests/ices.zunit
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
assert "$ZPLUGINS/test---atclone/readme.md" not_exists
}
@test 'make' {
run zinit as"null" id-as"test/make" atclone"printf 'all:\n\ttouch whatever\n' > Makefile" make"" for zdharma-continuum/null
run zinit as"null" id-as"test/make" atclone"printf 'all:\n\ttouch whatever\n' > Makefile" make"all" for zdharma-continuum/null
assert $state equals 0
assert "$ZPLUGINS/test---make/whatever" is_file
}
Expand Down
Loading

0 comments on commit 9f93790

Please sign in to comment.