Skip to content

Commit

Permalink
feat: configure, make, cmake, and build ices (#613) (#616)
Browse files Browse the repository at this point in the history
* Refactored 'configure' and 'make' ices
* New 'build' ice sets 'configure' and 'make ices if no flags are needed.
* New 'cmake' ice will build/install using 'cmake'
* Delete command now handles programs using 'make' and 'cmake' ices
* Setting `$ZINIT[DEBUG]` enables debug logging (i.e., `+zi-log "{dbg} message ..."`)
  • Loading branch information
vladdoster committed Jan 9, 2024
1 parent e2d477c commit 22e66db
Show file tree
Hide file tree
Showing 13 changed files with 630 additions and 513 deletions.
57 changes: 40 additions & 17 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,62 @@ 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 lua@5.1 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

zsh -l -c './build.zsh' && sudo chmod u+x ./zunit && cp ./zunit "$HOME/.local/bin/"
- name: "gh-r"
shell: zsh {0}
run: $HOME/.local/bin/zunit run --verbose tests/gh-r.zunit

- 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

run: zunit run 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

# - name: Run tests
# shell: zsh {0}
# run: |
# command -p ls -1 ./tests/*zunit \
# | parallel \
# --jobs=2 \
# --keep-order \
# --line-buffer \
# $HOME/.local/bin/zunit run
2 changes: 1 addition & 1 deletion .zunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ directories:
support: tests/_support
tests: tests
fail_fast: false
verbose: false
verbose: true
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
5 changes: 5 additions & 0 deletions tests/_support/annex_test_assertions
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ is_annex() {
assert ${PWD}/${${annex}//zinit-annex/z-a}.plugin.zsh is_file
assert ${PWD}/${${annex}//zinit-annex/z-a}.plugin.zsh is_readable
}

load_bin_gem_node(){
run zinit load @zdharma-continuum/zinit-annex-bin-gem-node
zinit default-ice --quiet from'gh-r'
}
70 changes: 42 additions & 28 deletions tests/_support/bootstrap
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/usr/bin/env zsh
setopt NO_GLOBAL_RCS NO_GLOBAL_EXPORT NO_RCS

# 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 @@ -19,50 +24,59 @@ if [[ ! -d ${TMP_ZUNIT} ]]; then
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;
typeset -gx zi_test_dir="${TMP_ZUNIT}"
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"
)
typeset -gxH ZPFX=
ZPFX="${zi_test_dir}/polaris"

command git diff > ${ZINIT[HOME_DIR]}/unstaged.diff
info 'creating test env'
# info 'creating test env'
git clone \
--quiet \
--depth=1 \
--dissociate \
--no-hardlinks \
--reference "${GIT_REPO}" \
file://${GIT_REPO:A} \
"${ZINIT[BIN_DIR]}"
"${ZINIT[BIN_DIR]}" >/dev/null
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 && \
git -C "${ZINIT[BIN_DIR]}" apply "${ZINIT[HOME_DIR]}/unstaged.diff" && \
chmod g-rwX "${ZINIT[HOME_DIR]}" && \
zcompile "${ZINIT[BIN_DIR]}/zinit.zsh"
)
zcompile "${ZINIT[BIN_DIR]}/zinit.zsh" >/dev/null
) >/dev/null
fi
(( $? != 0 )) && { error "Unable to copy ${GIT_REPO} to ${TMP_ZUNIT}" >&2; exit 1 }

source $ZINIT[BIN_DIR]/zinit.zsh
(( $? != 0 )) && { error "Unable to copy ${GIT_REPO} to ${TMP_ZUNIT}" >&2; exit 1 }
# ]]]
# Install Annexes [[[
info 'installing test dependencies'
for annex (binary-symlink default-ice); do
if [[ ! -d ${GIT_REPO}/tests/_support/$annex ]]; then;
git clone https://github.com/zdharma-continuum/zinit-annex-$annex ${GIT_REPO:A}/tests/_support/$annex
fi
zinit light ${GIT_REPO:A}/tests/_support/$annex
info "loaded $annex dependencies"
done
# ]]]
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"
(( $? != 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"

{
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

# vim:ft=zsh:sw=2:sts=2:et:foldmarker=[[[,]]]:foldmethod=marker
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
}

0 comments on commit 22e66db

Please sign in to comment.