From 94166fd7a26be9eaed3f0c97efa36bf7b9e1e4f8 Mon Sep 17 00:00:00 2001 From: Vladislav Doster Date: Sun, 10 Dec 2023 03:57:59 -0600 Subject: [PATCH] refactor: make, cmake, and configure ices Signed-off-by: Vladislav Doster --- .github/workflows/tests.yaml | 42 ++-- .zunit.yml | 4 +- README.md | 45 ++--- tests/_support/bootstrap | 49 +++-- tests/commands.zunit | 44 +++-- tests/gh-r.zunit | 166 ++++++++-------- tests/plugins.zunit | 157 ++++++++++----- zinit-autoload.zsh | 40 ++-- zinit-install.zsh | 364 ++++++++++++++--------------------- zinit.zsh | 69 ++++--- 10 files changed, 521 insertions(+), 459 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 95de3c4b8..0cfb6c58d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -26,7 +26,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: ["macos-latest", "ubuntu-latest"] + os: ["macos-latest","ubuntu-latest"] fail-fast: false steps: @@ -39,15 +39,30 @@ 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 --yes \ + autoconf automake autotools-dev \ + build-essential byacc\ + cmake curl \ + file \ + gcc gettext glibc-source grep \ + libc6 libc6-dev libevent-dev libncurses5-dev libncursesw5-dev libtool libuvc0 lua5.1 \ + m4 \ + ninja-build \ + pkg-config \ + unzip \ + xz-utils \ + zsh - 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 ninja ncurses pkg-config texinfo unzip xz zsh + brew link --force --overwrite ncurses - name: "install zunit" id: install-zunit @@ -56,23 +71,20 @@ jobs: 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: "plugins" + run: zunit run tests/plugins.zunit + - name: "gh-r" - run: zunit run --fail-fast --verbose tests/gh-r.zunit + run: zunit run tests/gh-r.zunit + + - name: "annexes" + run: zunit run tests/annexes.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 diff --git a/.zunit.yml b/.zunit.yml index 1a920e103..3dbb76568 100644 --- a/.zunit.yml +++ b/.zunit.yml @@ -3,5 +3,5 @@ directories: output: tests/_output support: tests/_support tests: tests -fail_fast: false -verbose: false +fail_fast: true +verbose: true diff --git a/README.md b/README.md index 64dfc6243..737439fb1 100644 --- a/README.md +++ b/README.md @@ -627,13 +627,7 @@ zi load docker/compose # can manage it for you if you like, run `./configure` and other `make`, etc. # Ice-mod `pick` selects a binary program to add to $PATH. You could also install the # package under the path $ZPFX, see: https://zdharma-continuum.github.io/zinit/wiki/Compiling-programs -zi ice \ - as"program" \ - atclone"rm -f src/auto/config.cache; ./configure" \ - atpull"%atclone" \ - make \ - pick"src/vim" -zi light vim/vim +zi configure make for @vim/vim # Scripts built at install (there's single default make target, "install", # and it constructs scripts by `cat'ing a few files). The make'' ice could also be: @@ -742,20 +736,22 @@ You may safely assume a given ice works with both plugins and snippets unless ex ### Command Execution After Cloning, Updating or Loading -| Modifier | Description | -| :----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `atclone` | Run command after cloning, within plugin's directory, e.g. `zinit ice atclone"echo Cloned"`. Ran also after downloading snippet. | -| `atinit` | Run command after directory setup (cloning, checking it, etc.) of plugin/snippet but before loading. | -| `atload` | Run command after loading, within plugin's directory. Can be also used with snippets. Passed code can be preceded with `!`, it will then be investigated (if using `load`, not `light`). | -| `atpull` | Run command after updating (**only if new commits are waiting for download**), within plugin's directory. If starts with "!" then command will be ran before `mv` & `cp` ices and before `git pull` or `svn update`. Otherwise it is ran after them. Can be `atpull'%atclone'`, to repeat `atclone` Ice-mod. | -| `configure` | Runs `./configure` script and by default changes the installation directory by passing `--prefix=$ZPFX` to the script. Runs before `make''` and after `make'!'`, you can pass `'!'` too to this ice (i.e.: `configure'!'`) to make it execute earlier – before `make'!'` and after `make'!!'`. If `#` given in the ice value then also executes script `./autogen.sh` first before running `./configure`. The script is run anyway if there is no `configure` script. Also, when there exist another build-system related files, then it is run if no `configure` script is found. Currently supported systems are: CMake, scons and meson, checked-for/run in this order | -| `countdown` | Causes an interruptable (by Ctrl-C) countdown 5…4…3…2…1…0 to be displayed before executing `atclone''`,`atpull''` and `make` ices | -| `cp` | Copy file after cloning or after update (then, only if new commits were downloaded). Example: `cp "docker-c* -> dcompose"`. Ran after `mv`. | -| `make` | Run `make` command after cloning/updating and executing `mv`, `cp`, `atpull`, `atclone` Ice mods. Can obtain argument, e.g. `make"install PREFIX=/opt"`. If the value starts with `!` then `make` is ran before `atclone`/`atpull`, e.g. `make'!'`. | -| `mv` | Move file after cloning or after update (then, only if new commits were downloaded). Example: `mv "fzf-* -> fzf"`. It uses `->` as separator for old and new file names. Works also with snippets. | -| `nocd` | Don't switch the current directory into the plugin's directory when evaluating the above ice-mods `atinit''`,`atload''`, etc. | -| `reset` | Invokes `git reset --hard HEAD` for plugins or `svn revert` for SVN snippets before pulling any new changes. This way `git` or `svn` will not report conflicts if some changes were done in e.g.: `atclone''` ice. For file snippets and `gh-r` plugins it invokes `rm -rf *`. | -| `run-atpull` | Always run the atpull hook (when updating), not only when there are new commits to be downloaded. | +| Modifier | Description | +| :----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `atclone` | Run command after cloning, within plugin's directory, e.g. `zinit ice atclone"echo Cloned"`. Ran also after downloading snippet. | +| `atinit` | Run command after directory setup (cloning, checking it, etc.) of plugin/snippet but before loading. | +| `atload` | Run command after loading, within plugin's directory. Can be also used with snippets. Passed code can be preceded with `!`, it will then be investigated (if using `load`, not `light`). | +| `atpull` | Run command after updating (**only if new commits are waiting for download**), within plugin's directory. If starts with "!" then command will be ran before `mv` & `cp` ices and before `git pull` or `svn update`. Otherwise it is ran after them. Can be `atpull'%atclone'`, to repeat `atclone` ice. | +| `build` | Will run `configure` and `make` ices. | +| `cmake` | Build and install a project via `cmake`. | +| `configure` | Run `./configure --prefix $ZPFX`. If `configure` script not found, autotools attempts to generate it and then runs `configure`. | +| `countdown` | Causes an interruptable (by Ctrl-C) countdown 5…4…3…2…1…0 to be displayed before executing `atclone''`,`atpull''` and `make` ices | +| `make` | Run `make prefix=$ZPFX && make prefix=$ZPFX install`. | +| `cp` | Copy file after cloning or after update (then, only if new commits were downloaded). Example: `cp "docker-c* -> dcompose"`. Ran after `mv`. | +| `mv` | Move file after cloning or after update (then, only if new commits were downloaded). Example: `mv "fzf-* -> fzf"`. It uses `->` as separator for old and new file names. Works also with snippets. | +| `nocd` | Don't switch the current directory into the plugin's directory when evaluating the above ice-mods `atinit''`,`atload''`, etc. | +| `reset` | Invokes `git reset --hard HEAD` for plugins or `svn revert` for SVN snippets before pulling any new changes. This way `git` or `svn` will not report conflicts if some changes were done in e.g.: `atclone''` ice. For file snippets and `gh-r` plugins it invokes `rm -rf *`. | +| `run-atpull` | Always run the atpull hook (when updating), not only when there are new commits to be downloaded. | ### Sticky-Emulation Of Other Shells @@ -1048,8 +1044,7 @@ $ cd $ZPFX/share Before the `configure''` ice appeared one would use `$ZPFX` as follows: ```zsh -zinit atclone'./configure --prefix=$ZPFX` atpull'%atclone' make \ - for universal-ctags/ctags +zinit configure make for universal-ctags/ctags ``` but now it's sufficient to do: @@ -1057,7 +1052,7 @@ but now it's sufficient to do: ```zsh # Will work for any build system # (supported are: configure, cmake, scons and meson) -zinit configure make for universal-ctags/ctags +zinit build for @universal-ctags/ctags ``` To set ZPFX, one should do (in `.zshrc` before loading `zinit`): @@ -1125,7 +1120,7 @@ zi as'null' lucid sbin wait'1' for \ paulirish/git-recent \ atload'export _MENU_THEME=legacy' \ arzzen/git-quick-stats \ - make'install' \ + make \ tj/git-extras \ make'GITURL_NO_CGITURL=1' \ sbin'git-url;git-guclone' \ diff --git a/tests/_support/bootstrap b/tests/_support/bootstrap index cb11e9a7c..98f59f2f7 100755 --- a/tests/_support/bootstrap +++ b/tests/_support/bootstrap @@ -1,5 +1,5 @@ #!/usr/bin/env zsh -setopt NO_GLOBAL_RCS NO_GLOBAL_EXPORT NO_RCS +setopt NO_GLOBAL_RCS NO_GLOBAL_EXPORT NO_RCS NO_ALIASES # Log functions [[[ function error(){ print -P "%F{red}[ERROR]%f: ${1}" && return 1; } @@ -19,14 +19,19 @@ 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 -g zi_dir="${TMP_ZUNIT}" +typeset -gxUA ZINIT +# DEBUG 'true' +ZINIT+=( + BIN_DIR ${zi_dir}/zinit.git + COMPLETIONS_DIR ${zi_dir}/completions SNIPPETS_DIR ${zi_dir}/snippets + HOME_DIR ${zi_dir} PLUGINS_DIR ${zi_dir}/plugins + ZCOMPDUMP_PATH ${zi_dir}/zcompdump ZPFX ${zi_dir}/polaris + POLARIS ${zi_dir}/polaris +) +typeset -gxH ZPFX="$ZINIT[POLARIS]" +# FORK 'vladdoster' REPO 'zinit-t' +# typeset -gxAUH ZINIT=(${(kv)CONFIG}) command git diff > ${ZINIT[HOME_DIR]}/unstaged.diff info 'creating test env' @@ -51,18 +56,24 @@ if [[ -s $ZINIT[HOME_DIR]/unstaged.diff ]]; then 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 } +hash -f +builtin hash -d zinit=$zi_dir +builtin hash -d zpfx=$zi_dir/polaris +source $zi_dir/zinit.git/zinit.zsh +(( $? != 0 )) && { error "Unable to source zinit" >&2; exit 1 } +hash -f +builtin hash -d zinit=$zi_dir +builtin hash -d zpfx=$zi_dir/polaris + # ]]] # 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 ++zi-log '{m} installing test dependencies' +zinit ver'feat/logging' for load @zdharma-continuum/zinit-annex-binary-symlink ++zi-log "{m} loaded $annex dependencies" # ]]] ++zi-log '{nl}{bar}' +zinit zstatus ++zi-log '{bar}{nl}' + # vim:ft=zsh:sw=2:sts=2:et:foldmarker=[[[,]]]:foldmethod=marker diff --git a/tests/commands.zunit b/tests/commands.zunit index 6a109b8f7..1c958778c 100644 --- a/tests/commands.zunit +++ b/tests/commands.zunit @@ -11,18 +11,13 @@ ZBIN="${ZPFX}/bin" } -@test 'delete --help' { - run zinit delete --help - assert $output contains 'zinit delete [options] [plugins...]' - assert $state equals 0 -} @test 'delete --all' { run zinit as'completion' is-snippet for @'https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker' assert $state equals 0 } -@test 'delete a snippet' { - run zinit id-as'git.zsh' is-snippet for @'OMZL::git.zsh' - run zinit delete --yes 'git.zsh' +@test 'delete --help' { + run zinit delete --help + assert $output contains 'zinit delete [options] [plugins...]' assert $state equals 0 } @test 'delete a plugin' { @@ -35,12 +30,9 @@ run zinit delete --yes mfaerevaag/wd assert $state equals 0 } - -@test 'plugins' { - run zinit plugins - assert $output contains 'Plugins' - assert $output contains 'Unloaded: ' - assert $output contains 'Loaded: ' +@test 'delete a snippet' { + run zinit id-as'git.zsh' is-snippet for @'OMZL::git.zsh' + run zinit delete --yes 'git.zsh' assert $state equals 0 } @test 'help' { @@ -51,12 +43,34 @@ done run zinit -help assert $output contains 'Unknown subcommand' - assert $state equals 1 + assert $state equals 1 +} + +@test 'plugins' { + run zinit plugins + assert $output contains 'Plugins' + assert $output contains 'Unloaded: ' + assert $output contains 'Loaded: ' + assert $state equals 0 } @test 'self-update' { run zinit self-update assert $output contains 'Already up-to-date.' assert $state equals 0 } +@test 'log_debug_unset' { + run eval '(( ${+ZINIT[DEBUG]} == 1 ))'; assert $state equals 1 + run +zi-log -n "{dbg} message" + assert "$output" contains ""; assert $state equals 0 + run +zi-log -n "{m} message" + assert "$output" contains "${ZINIT[col-m]} message"; assert $state equals 0 +} +@test 'log_debug_set' { + ZINIT+=( DEBUG "true" ) + run eval '(( ${+ZINIT[DEBUG]} == 1 ))' + assert $state equals 0 + run +zi-log -n "{dbg} message" + assert $output contains "${ZINIT[col-dbg]} message"; assert $state equals 0 +} # vim:ft=zsh:sw=2:sts=2:et:foldmarker={,}:foldmethod=marker diff --git a/tests/gh-r.zunit b/tests/gh-r.zunit index b2050f331..4a8feba36 100755 --- a/tests/gh-r.zunit +++ b/tests/gh-r.zunit @@ -1,11 +1,11 @@ #!/usr/bin/env zunit - @setup { HOME="$ZPFX" # Stops programs creating directories in user home export ZBIN="${ZPFX}/bin" + [[ ! -d $ZBIN ]] && mkdir -p "$ZBIN" export os_type="${OSTYPE//[0-9\.]*/}" - zinit default-ice --quiet from'gh-r' lbin + zinit default-ice --quiet from'gh-r' lbin'!' lman null } # @test 'atmos' { Universal Tool for DevOps and Cloud Automation (works with terraform, helm, helmfile, etc) @@ -50,7 +50,7 @@ $alacritty --version; assert $state equals 0 } @test 'alist' { # A file list program that supports multiple storage, powered by Gin and React - run zinit lbin'!* -> alist' for @alist-org/alist; assert $state equals 0 + run zinit for @alist-org/alist; assert $state equals 0 local alist="$ZBIN/alist"; assert "$alist" is_executable run $alist version; assert $state equals 0 } @@ -78,7 +78,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 @@ -86,7 +86,7 @@ run $bat --version; assert $state equals 0 } @test 'bazel' { # a fast, scalable, multi-language and extensible build system - run zinit lbin"!bazel* -> bazel" for @bazelbuild/bazel; assert $state equals 0 + run zinit for @bazelbuild/bazel; assert $state equals 0 local bazel="$ZBIN/bazel"; assert "$bazel" is_executable run $bazel --version; assert $state equals 0 } @@ -103,12 +103,12 @@ run $boilr --help; assert $state equals 0 } @test 'booklit' { # a pretty lit content authoring system - run zinit for lbin'!* -> booklit' @vito/booklit; assert $state equals 0 + run zinit for @vito/booklit; assert $state equals 0 local booklit="$ZBIN/booklit"; assert "$booklit" is_executable run "$booklit" --version; assert $state equals 0 } @test 'bottom' { # Yet another cross-platform graphical process/system monitor - run zinit lbin'!**/btm' for ClementTsang/bottom; assert $state equals 0 + run zinit lbin'btm' for ClementTsang/bottom; assert $state equals 0 local bottom="$ZBIN/btm"; assert "$bottom" is_executable run $bottom --version; assert $state equals 0 } @@ -119,27 +119,27 @@ run "$broot" --version; assert $state equals 0 } @test 'btop' { # A monitor of resources - run zinit lbin'!**/btop' for aristocratos/btop; assert $state equals 0 + run zinit for aristocratos/btop; assert $state equals 0 local btop="$ZBIN/btop"; assert "$btop" is_executable run $btop --version; assert $state equals 0 } @test 'calico' { # Cloud native networking and network security - run zinit lbin"!* -> calico" for @projectcalico/calico; assert $state equals 0 + run zinit for @projectcalico/calico; assert $state equals 0 local calico="$ZBIN/calico"; assert "$calico" is_executable run $calico --version; assert $state equals 0 } @test 'certificates' { # An opinionated helper for generating tls certificates - run zinit lbin"!* -> certificates" for @mvmaasakkers/certificates; assert $state equals 0 + run zinit for @mvmaasakkers/certificates; assert $state equals 0 local certificates="$ZBIN/certificates"; assert "$certificates" is_executable run $certificates --version; assert $state equals 0 } @test 'checkmake' { # experimental linter/analyzer for Makefiles - run zinit lbin'!checkmake* -> checkmake' for @mrtazz/checkmake; assert $state equals 0 + run zinit for @mrtazz/checkmake; assert $state equals 0 local checkmake="$ZBIN/checkmake"; assert "$checkmake" is_executable run $checkmake --version; assert $state equals 0 } @test 'cog' { # Containers for machine learning - run zinit lbin'!* -> cog' for @replicate/cog; assert $state equals 0 + run zinit for @replicate/cog; assert $state equals 0 local cog="$ZBIN/cog"; assert "$cog" is_executable run $cog --version; assert $state equals 0 } @@ -170,7 +170,7 @@ run $delta --version; assert $state equals 0 } @test 'difftastic' { # A structural diff that understands syntax - run zinit id-as'difft' for @Wilfred/difftastic; assert $state equals 0 + run zinit lbin'difft' for @Wilfred/difftastic; assert $state equals 0 local difftastic="$ZBIN/difft"; assert "$difftastic" is_executable run $difftastic --version; assert $state equals 0 } @@ -180,48 +180,48 @@ run $dive --version; assert $state equals 0 } @test 'docker-buildx' { # A monitor of resources - run zinit for lbin'!* -> buildx' @docker/buildx; assert $state equals 0 + run zinit for @docker/buildx; assert $state equals 0 local buildx="$ZBIN/buildx"; assert "$buildx" is_executable run $buildx version; assert $state equals 0 } @test 'docker-compose' { # Define and run multi-container applications with Docker - run zinit lbin'!* -> docker-compose' for @docker/compose; assert $state equals 0 - local dc="$ZBIN/docker-compose"; assert "$dc" is_executable + run zinit for @docker/compose; assert $state equals 0 + local dc="$ZBIN/compose"; assert "$dc" is_executable run $dc --version; assert $state equals 0 } @test 'docker-credential-helpers' { # A monitor of resources [[ $OSTYPE =~ 'linux*' ]] && skip "on $os_type" - run zinit for lbin'!* -> docker-credential-desktop' @docker/docker-credential-helpers; assert $state equals 0 - local credential_desktop="$ZBIN/docker-credential-desktop"; assert "$credential_desktop" is_executable + run zinit for id-as'docker-credential-osxkeychain' @docker/docker-credential-helpers; assert $state equals 0 + local credential_desktop="$ZBIN/docker-credential-osxkeychain"; assert "$credential_desktop" is_executable run $credential_desktop version; assert $state equals 0 } @test 'documize' { # Modern Confluence alternative designed for internal & external docs, built with Go & Ember JS - run zinit lbin'!* -> documize' for @documize/community; assert $state equals 0 + run zinit for id-as'documize' @documize/community; assert $state equals 0 local documize="$ZBIN/documize"; assert "$documize" is_executable run $documize version; assert $state equals 0 } @test 'dstask' { # Git powered terminal-based todo/note manager -- markdown note page per task - run zinit lbin'!*->dstask' bpick'^*import*' for @naggie/dstask; assert $state equals 0 + run zinit bpick'^*import*' for @naggie/dstask; assert $state equals 0 local dstask="$ZBIN/dstask"; assert "$dstask" is_executable run $dstask version; assert $state equals 0 } @test 'dua' { # View disk space usage and delete unwanted data, fast - run zinit ver'v2.20.3' lbin'!**/dua' for @Byron/dua-cli; assert $state equals 0 + run zinit lbin'!dua' ver'v2.20.3' for @Byron/dua-cli; assert $state equals 0 local dua="$ZBIN/dua"; assert "$dua" is_executable - run $dua --version; assert $state equals 0 + run "$dua" --version; assert $state equals 0 } @test 'duci' { # The simple CI server - run zinit lbin'!**/duci' for @duck8823/duci; assert $state equals 0 + run zinit for @duck8823/duci; assert $state equals 0 local duci="$ZBIN/duci"; assert "$duci" is_executable run $duci version; assert $state equals 0 } @test 'dust' { # A more intuitive version of du in rust - run zinit lbin'!**/dust' for @bootandy/dust; assert $state equals 0 + run zinit for @bootandy/dust; assert $state equals 0 local dust="$ZBIN/dust"; assert "$dust" is_executable run $dust --version; assert $state equals 0 } @test 'dyff' { # diff tool for YAML files, and sometimes JSON - run zinit lbin'!**/dyff' for @homeport/dyff; assert $state equals 0 + run zinit for @homeport/dyff; assert $state equals 0 local dyff="$ZBIN/dyff"; assert "$dyff" is_executable run $dyff version; assert $state equals 0 } @@ -232,12 +232,12 @@ run $dysk --version; assert $state equals 0 } @test 'etcd' { # Distributed reliable key-value store for the most critical data of a distributed system - run zinit lbin'!**/etcd' for @etcd-io/etcd; assert $state equals 0 + run zinit for @etcd-io/etcd; assert $state equals 0 local etcd="$ZBIN/etcd"; assert "$etcd" is_executable run $etcd --version; assert $state equals 0 } @test 'exa' { # A modern replacement for ls - run zinit lbin'!**/exa' for @ogham/exa; assert $state equals 0 + run zinit for @ogham/exa; assert $state equals 0 local exa="$ZBIN/exa"; assert "$exa" is_executable run $exa --version; assert $state equals 0 } @@ -245,7 +245,7 @@ [[ $OSTYPE =~ 'darwin*' ]] && skip "on $os_type" run zinit ver'v0.31.0' for @pkolaczk/fclones; assert $state equals 0 local fclones="$ZBIN/fclones"; assert "$fclones" is_executable - run "$fclones" --help; assert $state equals 0 + run "$fclones" --version; assert $state equals 0 } @test 'fd' { # A fast, simple, and user-friendly alternative to find run zinit for @sharkdp/fd; assert $state equals 0 @@ -263,7 +263,7 @@ run $fogg version; assert $state equals 0 } @test 'fx' { # Terminal JSON viewer - run zinit lbin'!* -> fx' for @antonmedv/fx; assert $state equals 0 + run zinit for @antonmedv/fx; assert $state equals 0 local fx="$ZBIN/fx"; assert "$fx" is_executable run $fx -v; assert $state equals 0 } @@ -274,27 +274,27 @@ } @test 'gaper' { # Builds and restarts a Go project when it crashes or some watched file changes [[ $OSTYPE =~ "linux*" ]] && skip "on $os_type" - run zinit lbin'!**/gaper' for @maxcnunes/gaper; assert $state equals 0 + run zinit lbin'!gaper' for @maxcnunes/gaper; assert $state equals 0 local gaper="$ZBIN/gaper"; assert "$gaper" is_executable run $gaper --version; assert $state equals 0 } @test 'gdu' { # Fast disk usage analyzer with console interface written in Go - run zinit lbin'!* -> gdu' for @dundee/gdu; assert $state equals 0 + run zinit for @dundee/gdu; assert $state equals 0 local gdu="$ZBIN/gdu"; assert "$gdu" is_executable run $gdu --version; assert $state equals 0 } @test 'gf' { # Fast disk usage analyzer with console interface written in Go - run zinit lbin'!* -> gf' for @gogf/gf; assert $state equals 0 + run zinit for @gogf/gf; assert $state equals 0 local gf="$ZBIN/gf"; assert "$gf" is_executable run $gf --version; assert $state equals 0 } @test 'ggsrun' { # This is a CLI tool to execute Google Apps Script (GAS) at own terminal on local PC. Also this CLI tool can be used for managing files in Google Drive for OAuth2 and Service Account - run zinit lbin'!* -> ggsrun' ver'v2.0.0' for @tanaikech/ggsrun; assert $state equals 0 + run zinit ver'v2.0.0' for @tanaikech/ggsrun; assert $state equals 0 local git_sizer="$ZBIN/ggsrun"; assert "$git_sizer" is_executable run $git_sizer --version; assert $state equals 0 } @test 'gh-cli' { # GitHub’s official command line tool - run zinit lbin'!**/gh' for @cli/cli; assert $state equals 0 + run zinit lbin'gh' for @cli/cli; assert $state equals 0 local gh_cli="$ZBIN/gh"; assert "$gh_cli" is_executable run $gh_cli --version; assert $state equals 0 } @@ -345,8 +345,8 @@ run $git_sizer version; assert $state equals 0 } @test 'go-swagger' { # Swagger 2.0 implementation for go - run zinit lbin'!* -> go-swagger' for @go-swagger/go-swagger; assert $state equals 0 - local git_sizer="$ZBIN/go-swagger"; assert "$git_sizer" is_executable + run zinit id-as'swagger' for @go-swagger/go-swagger; assert $state equals 0 + local git_sizer="$ZBIN/swagger"; assert "$git_sizer" is_executable run $git_sizer version; assert $state equals 0 } @test 'gojq' { # Pure Go implementation of jq @@ -361,7 +361,7 @@ } @test 'gosu' { # Simple Go-based setuid+setgid+setgroups+exec [[ $OSTYPE =~ "darwin*" ]] && skip "on $os_type" - run zinit lbin'!* -> gosu' for @tianon/gosu; assert $state equals 0 + run zinit for @tianon/gosu; assert $state equals 0 local gosu="$ZBIN/gosu"; assert "$gosu" is_executable run $gosu --version; assert $state equals 0 } @@ -391,7 +391,7 @@ run $gron --version; assert $state equals 0 } @test 'hadolint' { # Dockerfile linter, validate inline bash, written in Haskell - run zinit ver'v2.12.1-beta' lbin'!hadolint* -> hadolint' for @hadolint/hadolint; assert $state equals 0 + run zinit ver'v2.12.1-beta' for @hadolint/hadolint; assert $state equals 0 local hadolint="$ZBIN/hadolint"; assert "$hadolint" is_executable run $hadolint --version; assert $state equals 0 } @@ -403,7 +403,7 @@ run $heksa --version; assert $state equals 0 } @test 'helix' { # A post-modern modal text editor - run zinit lbin'!**/hx' for @helix-editor/helix; assert $state equals 0 + run zinit lbin'hx' for @helix-editor/helix; assert $state equals 0 local helix="$ZBIN/hx"; assert "$helix" is_executable run $helix --version; assert $state equals 0 } @@ -413,12 +413,12 @@ run $hexyl --version; assert $state equals 0 } @test 'hit-on' { # Git Workflow Helper Tool - run zinit lbin'!* -> hit' for kowainik/hit-on; assert $state equals 0 + run zinit id-as'hit' for kowainik/hit-on; assert $state equals 0 local hit="$ZBIN/hit"; assert "$hit" is_executable run $hit --version; assert $state equals 0 } @test 'hoofli' { # Generate PlantUML diagrams from Chrome or Firefox network inspection - run zinit lbin'!* -> hoofli' for @dnnrly/hoofli; assert $state equals 0 + run zinit for @dnnrly/hoofli; assert $state equals 0 local hoofli="$ZBIN/hoofli"; assert "$hoofli" is_executable run $hoofli -h; assert $state equals 0 } @@ -434,7 +434,7 @@ run "$htmlq" --version; assert $state equals 0 } @test 'hyperfine' { # A command-line benchmarking tool - run zinit bpick'*tar.gz*' for @sharkdp/hyperfine; assert $state equals 0 + run zinit for @sharkdp/hyperfine; assert $state equals 0 local hyperfine="$ZBIN/hyperfine"; assert "$hyperfine" is_executable run $hyperfine --version; assert $state equals 0 } @@ -449,22 +449,27 @@ run $igo version; assert $state equals 0 } @test 'insect' { # High precision scientific calculator with support for physical units - run zinit ver'v5.7.0' lbin'!* -> insect' for @sharkdp/insect; assert $state equals 0 + run zinit ver'v5.7.0' for @sharkdp/insect; assert $state equals 0 local insect="$ZBIN/insect"; assert "$insect" is_executable run $insect help; assert $state equals 0 } @test 'ipinfo' { # Official Command Line Interface for the IPinfo API (IP geolocation and other types of IP data) - run zinit for id-as'ipinfo' lbin'*->ipinfo' @ipinfo/cli; assert $state equals 0 + run zinit for id-as'ipinfo' @ipinfo/cli; assert $state equals 0 local cli="$ZBIN/ipinfo"; assert "$cli" is_executable run "$cli" --version; assert $state equals 0 } +@test 'jc' { # CLI tool and python library that converts the output of popular command-line tools, file-types, and common strings to JSON, YAML, or Dictionaries. This allows piping of output to tools like jq and simplifying automation scripts. + run zinit for @kellyjonbrazil/jc; assert $state equals 0 + local jc="$ZBIN/jc"; assert "$jc" is_executable + run "$jc" --version; assert $state equals 0 +} @test 'joincap' { # Merge multiple pcap files together, gracefully - run zinit lbin'!* -> joincap' for @assafmo/joincap; assert $state equals 0 + run zinit for @assafmo/joincap; assert $state equals 0 local joincap="$ZBIN/joincap"; assert "$joincap" is_executable run $joincap --version; assert $state equals 0 } @test 'jq' { # Command-line JSON processor - run zinit lbin'!* -> jq' for jqlang/jq; assert $state equals 0 + run zinit for jqlang/jq; assert $state equals 0 local jq="$ZBIN/jq"; assert "$jq" is_executable run $jq --version; assert $state equals 0 } @@ -475,8 +480,8 @@ } @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 zinit for lbin'!*cli' @keepassxreboot/keepassxc; assert $state equals 0 + local keepassxc="$ZBIN/keepassxc"; assert "$keepassxc" is_executable run $keepassxc --version; assert $state equals 0 } @test 'ko' { # Build and deploy Go applications on Kubernetes @@ -490,13 +495,13 @@ run $kopia --version; assert $state equals 0 } @test 'krew' { # Build and deploy Go applications on Kubernetes - run zinit lbin'!krew* -> krew' for @kubernetes-sigs/krew; assert $state equals 0 + run zinit for @kubernetes-sigs/krew; assert $state equals 0 local krew="$ZBIN/krew"; assert "$krew" is_executable run $krew version; assert $state equals 0 } -@test 'kubedb' { # `kubectl` plugin for KubeDB - run zinit for id-as'kubedb' lbin'*->kubedb' @kubedb/cli; assert $state equals 0 - local cli="$ZBIN/kubedb"; assert "$cli" is_executable +@test 'kubectl-dba' { # kubectl` plugin for KubeDB + run zinit for id-as'kubectl-dba' @kubedb/cli; assert $state equals 0 + local cli="$ZBIN/kubectl-dba"; assert "$cli" is_executable run "$cli" version; assert $state equals 0 } @test 'lazygit' { # simple terminal UI for git commands @@ -505,7 +510,7 @@ run $lazygit --version; assert $state equals 0 } @test 'lemmeknow' { # The fastest way to identify anything - run zinit lbin'!* -> lemmeknow' for @swanandx/lemmeknow; assert $state equals 0 + run zinit for @swanandx/lemmeknow; assert $state equals 0 local lemmeknow="$ZBIN/lemmeknow"; assert "$lemmeknow" is_executable run "$lemmeknow" --version; assert $state equals 0 } @@ -532,7 +537,7 @@ } @test 'macchina' { # A system information frontend with an emphasis on performance [[ $OSTYPE =~ 'darwin*' ]] && skip "skipped on $os_type" - run zinit lbin'!* -> macchina' for @macchina-cli/macchina; assert $state equals 0 + run zinit for @macchina-cli/macchina; assert $state equals 0 local macchina="$ZBIN/macchina"; assert "$macchina" is_executable run $macchina --version; assert $state equals 0 } @@ -543,7 +548,7 @@ } @test 'mas' { # Mac App Store command line interface [[ $OSTYPE =~ 'linux*' ]] && skip "skipped on $os_type" - run zinit lbin'!**/bin/mas' for @mas-cli/mas; assert $state equals 0 + run zinit for @mas-cli/mas; assert $state equals 0 local mas="$ZBIN/mas"; assert "$mas" is_executable run $mas version; assert $state equals 0 } @@ -569,20 +574,14 @@ } @test 'miniserve' { # For when you really just want to serve some files over HTTP right now! [[ $OSTYPE =~ 'darwin*' ]] && skip "skipped on $os_type" - run zinit lbin'!* -> miniserve' for @svenstaro/miniserve; assert $state equals 0 + run zinit for lbin'!*' @svenstaro/miniserve; assert $state equals 0 local miniserve="$ZBIN/miniserve"; assert "$miniserve" is_executable - run $miniserve --help; assert $state equals 0 } @test 'mkcert' { # A simple zero-config tool to make locally trusted development certificates - run zinit lbin'!* -> mkcert' for @FiloSottile/mkcert; assert $state equals 0 + run zinit for @FiloSottile/mkcert; assert $state equals 0 local mkcert="$ZBIN/mkcert"; assert "$mkcert" is_executable run $mkcert --version; assert $state equals 0 } -@test 'mmake' { # A Make/rake-like dev tool using Go - run zinit for ver'v1.4.0' @tj/mmake; assert $state equals 0 - local mmake="$ZBIN/mmake"; assert "$mmake" is_executable - run $mmake --version; assert $state equals 0 -} @test 'mmv' { # rename multiple files with editor run zinit for @itchyny/mmv; assert $state equals 0 local mmv="$ZBIN/mmv"; assert "$mmv" is_executable @@ -594,23 +593,23 @@ run $mob --version; assert $state equals 0 } @test 'mocword' { # Predict next words - run zinit lbin'!**/mocword* -> mocword' for @high-moctane/mocword; assert $state equals 0 + run zinit for @high-moctane/mocword; assert $state equals 0 local mocword="$ZBIN/mocword"; assert "$mocword" is_executable run $mocword --version; assert $state equals 0 } @test 'monolith' { # CLI tool for saving complete web pages as a single HTML file [[ $OSTYPE =~ 'darwin*' ]] && skip "skipped on $os_type" - run zinit lbin'!* -> monolith' for @Y2Z/monolith; assert $state equals 0 + run zinit for @Y2Z/monolith; assert $state equals 0 local monolith="$ZBIN/monolith"; assert "$monolith" is_executable run $monolith --version; assert $state equals 0 } @test 'moonwalk' { # Cover your tracks during Linux Exploitation by leaving zero traces on system logs and filesystem timestamps - run zinit lbin'!**/moonwalk* -> moonwalk' for @mufeedvh/moonwalk; assert $state equals 0 + run zinit for @mufeedvh/moonwalk; assert $state equals 0 local moonwalk="$ZBIN/moonwalk"; assert "$moonwalk" is_executable run $moonwalk --version; assert $state equals 0 } @test 'navi' { # An interactive cheatsheet tool for the command-line - run zinit lbin'* -> navi' for @denisidoro/navi; assert $state equals 0 + run zinit for @denisidoro/navi; assert $state equals 0 local navi="$ZBIN/navi"; assert "$navi" is_executable run $navi --version; assert $state equals 0 } @@ -686,7 +685,7 @@ run "$rclone" --version; assert $state equals 0 } @test 'reg' { # Docker registry v2 command line client and repo listing generator with security checks - run zinit lbin'!* -> reg' for @genuinetools/reg; assert $state equals 0 + run zinit for @genuinetools/reg; assert $state equals 0 local reg="$ZBIN/reg"; assert "$reg" is_executable run "$reg" version; assert $state equals 0 } @@ -697,7 +696,7 @@ run "$rip" --version; assert $state equals 0 } @test 'ripgrep' { # Recursively searches directories for a regex pattern while respecting your gitignore - run zinit lbin'!**/rg' for @BurntSushi/ripgrep; assert $state equals 0 + run zinit id-as'rg' for @BurntSushi/ripgrep; assert $state equals 0 local rg="$ZBIN/rg"; assert "$rg" is_executable run "$rg" --version; assert $state equals 0 } @@ -713,7 +712,7 @@ } @test 'rust-analyzer' { # A Rust compiler front-end for IDEs [[ $OSTYPE =~ "linux*" ]] && skip "skipped on $os_type" - run zinit lbin'!* -> rust-analyzer' for @rust-lang/rust-analyzer; assert $state equals 0 + run zinit for @rust-lang/rust-analyzer; assert $state equals 0 local rust_analyzer="$ZBIN/rust-analyzer"; assert "$rust_analyzer" is_executable run "$rust_analyzer" --version; assert $state equals 0 } @@ -733,7 +732,7 @@ run "$shellcheck" --version; assert $state equals 0 } @test 'shfmt' { # A shell parser, formatter, and interpreter with bash support - run zinit lbin'!**/sh* -> shfmt' for @mvdan/sh; assert $state equals 0 + run zinit id-as'shfmt' for @mvdan/sh; assert $state equals 0 local shfmt="$ZBIN/shfmt"; assert "$shfmt" is_executable run $shfmt --version; assert $state equals 0 } @@ -758,17 +757,17 @@ run "$stern" --version; assert $state equals 0 } @test 'tealdeer' { # A very fast implementation of tldr in Rust - run zinit lbin'!tealdeer* -> tealdeer' for @dbrgn/tealdeer; assert $state equals 0 + run zinit for @dbrgn/tealdeer; assert $state equals 0 local tealdeer="$ZBIN/tealdeer"; assert "$tealdeer" is_executable run "$tealdeer" --version; assert $state equals 0 } @test 'tin-summer' { # Find build artifacts that are taking up disk space - run zinit for @vmchale/tin-summer; assert $state equals 0 + run zinit for lbin'sn' @vmchale/tin-summer; assert $state equals 0 local tin_summer="$ZBIN/sn"; assert "$tin_summer" is_executable run "$tin_summer" --version; assert $state equals 0 } @test 'tokei' { # Count your code, quickly. - run zinit lbin'!*tokei -> tokei' ver'v12.1.1' for @XAMPPRocky/tokei; assert $state equals 0 + run zinit ver'v12.1.1' for @XAMPPRocky/tokei; assert $state equals 0 local tokei="$ZBIN/tokei"; assert "$tokei" is_executable run $tokei --version; assert $state equals 0 } @@ -787,10 +786,15 @@ local tv="$ZBIN/tv"; assert "$tv" is_executable run $tv --version; assert $state equals 0 } -@test 'up' { # Deploy infinitely scalable serverless apps, apis, and sites in seconds to AWS - run zinit lbin'!up* -> up' for akavel/up; assert $state equals 0 +@test 'up-1' { # Deploy infinitely scalable serverless apps, apis, and sites in seconds to AWS + run zinit for @apex/up; assert $state equals 0 + local up="$ZBIN/up"; assert "$up" is_executable + run "$up" --version; assert $state equals 0 +} +@test 'up-2' { # ultimate plumber is a tool for writing linux pipes with instant live preview + run zinit for @akavel/up; assert $state equals 0 local up="$ZBIN/up"; assert "$up" is_executable - run $up -h; assert $output contains "up is the Ultimate Plumber" + run "$up" -h; assert $output contains "up is the Ultimate Plumber" } @test 'volta-cli' { # JS Toolchains as Code [[ "$OSTYPE" =~ 'linux*' ]] && skip 'Volta CLI skipped on Linux' @@ -805,17 +809,17 @@ run "$watchexec" --version; assert $state equals 0 } @test 'whalebrew' { # Homebrew, but with Docker images - run zinit lbin'!* -> whalebrew' for whalebrew/whalebrew; assert $state equals 0 + run zinit for whalebrew/whalebrew; assert $state equals 0 local whalebrew="$ZBIN/whalebrew"; assert "$whalebrew" is_executable run $whalebrew version; assert $state equals 0 } @test 'wifiqr' { # Create a QR code with your Wi-Fi login details - run zinit lbin'!* -> wifiqr' for reugn/wifiqr; assert $state equals 0 + run zinit for reugn/wifiqr; assert $state equals 0 local wifiqr="$ZBIN/wifiqr"; assert "$wifiqr" is_executable run $wifiqr --version; assert $state equals 0 } @test 'wtf' { # The personal information dashboard for your terminal - run zinit lbin'!**/wtf* -> wtf' for wtfutil/wtf; assert $state equals 0 + run zinit for wtfutil/wtf; assert $state equals 0 local wtf="$ZBIN/wtf"; assert "$wtf" is_executable run $wtf --version; assert $state equals 0 } @@ -836,7 +840,7 @@ run $yabai --version; assert $state equals 0 } @test 'yq' { # a portable command-line YAML, JSON and XML processor - run zinit lbin'!* -> yq' for @mikefarah/yq; assert $state equals 0 + run zinit for @mikefarah/yq; assert $state equals 0 local yq="$ZBIN/yq"; assert "$yq" is_executable run $yq --version; assert $state equals 0 } diff --git a/tests/plugins.zunit b/tests/plugins.zunit index 251bb23a1..117dfd064 100755 --- a/tests/plugins.zunit +++ b/tests/plugins.zunit @@ -1,55 +1,120 @@ #!/usr/bin/env zunit - @setup { - zinit default-ice as'null' light-mode nocompile nocompletions - ZBIN=$ZPFX/bin - export LC_CTYPE=C - export LANG=C -} - -# @test 'nnn' { -# run zinit light-mode for jarun/nnn -# zinit cd jarun/nnn -# run PREFIX=$ZPFX make install; assert $state equals 0 -# local nnn="$ZPFX/bin/nnn"; assert $nnn is_executable -# $nnn -V; assert $state equals 0 + HOME="$ZINIT[HOME_DIR]" + export ZBIN="${ZINIT[POLARIS]}/bin" +} + +# @test 'cmatrix' { +# run zinit build for @abishekvashok/cmatrix; +# local cmatrix="$ZBIN/cmatrix"; assert "$cmatrix" is_executable +# run "$cmatrix" -V; assert $state equals 0 +# # ensure cmake artifacts are deleted +# zinit delete --yes abishekvashok/cmatrix; assert $state equals 0 +# run "$cmatrix"; assert $state equals 127 # } -@test 'pipes' { - run zinit for @pipeseroni/pipes.sh - # zinit cd pipeseroni/pipes.sh - run zinit run pipeseroni/pipes.sh make PREFIX=$ZPFX install; assert $state equals 0 - local pipes="$ZBIN/pipes.sh"; assert $pipes is_executable - $pipes -v; assert $state equals 0 -} -@test 'tree' { - run zinit light-mode for Old-Man-Programmer/tree - zinit cd Old-Man-Programmer/tree - run make PREFIX=$ZPFX install; assert $state equals 0 - local tree="$ZBIN/tree"; assert $tree is_executable - $tree -v; assert $state equals 0 +@test 'figlet' { + run zinit make for @cmatsuoka/figlet; assert $state equals 0 + local figlet="$ZBIN/figlet"; assert "$figlet" is_executable + run "$figlet" -I 1; assert $state equals 0 +} +@test 'htop' { + run zinit build for @htop-dev/htop; assert $state equals 0 + local htop="$ZBIN/htop"; assert "$htop" is_executable + run "$htop" --version; assert $state equals 0 +} +@test 'bash' { + run zinit build for @bminor/bash; assert $state equals 0 + local bash="$ZBIN/bash"; assert $bash is_executable + run "$bash" --version; assert $state equals 0 +} +@test 'ctags' { + run zinit build for @universal-ctags/ctags; assert $state equals 0 + local ctags="$ZBIN/ctags"; assert "$ctags" is_executable + run "$ctags" --version; assert $state equals 0 +} +@test 'lua-format' { + run zinit cmake for @Koihik/LuaFormatter; assert $state equals 0 + local lua_format="$ZBIN/lua-format"; assert "$lua_format" is_executable + run "$lua_format" --version; assert $state equals 0 +} +@test 'jq' { + run zinit build for @jqlang/jq; assert $state equals 0 + local jq="$ZBIN/jq"; assert "$jq" is_executable + run "$jq" --version; assert $state equals 0 +} +@test 'ncurses' { + builtin print -v cfg_opts -- '--enable-'{widec,termcap} + run zinit configure"$cfg_opts" make for @mirror/ncurses; assert $state equals 0 + local ncurses="$ZBIN/clear"; assert "$ncurses" is_executable + run "$ncurses" -V; assert $state equals 0 +} +@test 'neofetch' { + run zinit make for @dylanaraps/neofetch; assert $state equals 0 + local neofetch="$ZBIN/neofetch"; assert "$neofetch" is_executable + run "$neofetch" --version; assert $state equals 1; assert $output contains 'Neofetch' +} +@test 'neovim-make' { + run zinit make for @neovim/neovim; assert $state equals 0 + local neovim="$ZBIN/nvim"; assert $neovim is_executable + run "$neovim" --version; assert $state equals 0 + + nvim_ver="$($neovim --version | head -n1 | awk '{print $2}')"; + nvim_commit="$(git --work-tree=$ZINIT[PLUGINS_DIR]/neovim---neovim rev-parse --short HEAD)"; + print -lPr " " "nvim ver: %F{blue}$nvim_ver%f" "nvim commit sha: %F{blue}$nvim_commit%f" "check: [[ %F{blue}$nvim_ver%f = %F{blue}*$nvim_commit(#e)%f ]]" + [[ $nvim_ver = *$nvim_commit(#e) ]] && print -P "%F{green}ok%f" + + run zinit delete --yes neovim/neovim; assert $state equals 0 +} +@test 'neovim-cmake' { + run zinit cmake for @neovim/neovim; assert $state equals 0 + local neovim="$ZBIN/nvim"; assert $neovim is_executable + run "$neovim" --version; assert $state equals 0 + + nvim_ver="$($neovim --version | head -n1 | awk '{print $2}')"; + nvim_commit="$(git --work-tree=$ZINIT[PLUGINS_DIR]/neovim---neovim rev-parse --short HEAD)"; + print -lPr " " "nvim ver: %F{blue}$nvim_ver%f" "nvim commit sha: %F{blue}$nvim_commit%f" "check: [[ %F{blue}$nvim_ver%f = %F{blue}*$nvim_commit(#e)%f ]]" + [[ $nvim_ver = *$nvim_commit(#e) ]] && print -P "%F{green}ok%f" + + run zinit delete --yes neovim/neovim; assert $state equals 0 +} +@test 'tmux' { + if [[ $OSTYPE =~ 'darwin*' ]]; then + run zinit configure'--disable-utf8proc' make for @tmux/tmux; assert $state equals 0 + else + run zinit build for @tmux/tmux; assert $state equals 0 + fi + local tmux="$ZBIN/tmux"; assert $tmux is_executable + run "$tmux" -V; assert $state equals 0 } @test 'vim' { - run zinit light-mode for vim/vim - zinit cd vim/vim - run ./configure --prefix=$ZPFX && make PREFIX=$ZPFX install - assert $state equals 0 + run zinit build for @vim/vim; assert $state equals 0 local vim="$ZBIN/vim"; assert $vim is_executable - $vim --version; assert $state equals 0 -} -@test 'zsh-completions' { - run zinit light-mode for zsh-users/zsh-completions - zinit cd zsh-users/zsh-completions - run zinit creinstall -q .; assert $state equals 0 - local broken_completions=($(echo "$ZINIT[COMPLETIONS_DIR]"/*(-@))); assert "${#broken_completions[@]}" equals 0 -} -# @test 'zsh_bin' { -# run zinit as'null' sbin'bin/zsh' for @romkatv/zsh-bin -# assert $state equals 0 -# local zsh_static="$ZPFX/bin/zsh" -# assert "$zsh_static" is_executable -# $zsh_static --help -# assert $state equals 0 + run "$vim" --version; assert $state equals 0 + run zinit delete --yes vim/vim; assert $state equals 0 +} +@test 'zsh' { + # run zinit configure'--with-tcsetpgrp' make'install.bin' for @zsh-users/zsh; assert $state equals 0 + run zinit configure'--with-tcsetpgrp' atclone"./Util/preconfig" make'install.bin' for @zsh-users/zsh; assert $state equals 0 + local zsh="$ZBIN/zsh"; assert $zsh is_executable + run "$zsh" --version; assert $state equals 0 + run zinit delete --yes zsh-users/zsh; assert $state equals 0 + run "$zsh" --version; assert $state equals 127 +} + +# =========== +# Flaky tests +# =========== +# @test 'stow' { +# run zinit configure'--without-pmdir' make for @aspiers/stow; assert $state equals 0 +# local stow="$ZBIN/stow"; assert "$stow" is_executable +# run "$stow" --version; assert $state equals 0 +# } +# @test 'zsh-completions' { +# run zinit light-mode for zsh-users/zsh-completions +# zinit cd zsh-users/zsh-completions +# run zinit creinstall -q .; assert $state equals 0 +# local broken_completions=($(echo "$ZINIT[COMPLETIONS_DIR]"/*(-@N))); assert "$#broken_completions[@]" equals 0 # } -# vim:ft=zsh:sw=2:sts=2:et:foldmarker=@test,}:foldmethod=marker +# vim:ft=zsh:sw=2:sts=2:et:foldmarker={,}:foldmethod=indent diff --git a/zinit-autoload.zsh b/zinit-autoload.zsh index bed1eccec..39011924d 100644 --- a/zinit-autoload.zsh +++ b/zinit-autoload.zsh @@ -1697,24 +1697,37 @@ print -- "\nAvailable ice-modifiers:\n\n${ice_order[*]}" done } # ]]] # FUNCTION: .zinit-run-delete-hooks [[[ -.zinit-run-delete-hooks() { +.zinit-run-delete-hooks () { + local make_path=$5/Makefile mfest_path=$5/build/install_manifest.txt quiet='2>/dev/null 1>&2' + if [[ -f $make_path ]] && grep '^uninstall:' $make_path &> /dev/null; then + +zi-log "{m} Make uninstall" + command make -C "${make_path:h}" {'CMAKE_INSTALL_PREFIX','PREFIX','prefix'}="$ZPFX" --ignore-errors uninstall + if (( $? == 0 )); then + +zi-log "{m} Successful Make uninstall" + fi + elif [[ -f $mfest_path ]]; then + +zi-log "{m} Cmake uninstall" + if ! command cmake --build ${mfest_path:h} --target uninstall >/dev/null; then + xargs rm -rf < "$mfest_path" 2>/dev/null 1>&2 + if (( $? == 0 )); then + +zi-log "{m} Successful Cmake uninstall" + fi + fi + fi + find $ZPFX -depth -type d -empty -delete &> /dev/null if [[ -n ${ICE[atdelete]} ]]; then - .zinit-countdown "atdelete" && ( (( ${+ICE[nocd]} == 0 )) && \ - { builtin cd -q "$5" && eval "${ICE[atdelete]}"; ((1)); } || \ - eval "${ICE[atdelete]}" ) + ( + (( ${+ICE[nocd]} == 0 )) && { + builtin cd -q "$5" && eval "${ICE[atdelete]}" + ((1)) + } || eval "${ICE[atdelete]}" + ) fi - local -a arr local key - - # Run annexes' atdelete hooks - reply=( - ${(on)ZINIT_EXTS2[(I)zinit hook:atdelete-pre <->]} - ${(on)ZINIT_EXTS[(I)z-annex hook:atdelete-<-> <->]} - ${(on)ZINIT_EXTS2[(I)zinit hook:atdelete-post <->]} - ) + reply=(${(on)ZINIT_EXTS2[(I)zinit hook:atdelete-pre <->]} ${(on)ZINIT_EXTS[(I)z-annex hook:atdelete-<-> <->]} ${(on)ZINIT_EXTS2[(I)zinit hook:atdelete-post <->]}) for key in "${reply[@]}"; do - arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" ) + arr=("${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}") "${arr[5]}" "$1" "$2" $3 "$4" "$5" "${${key##(zinit|z-annex) hook:}%% <->}" delete:TODO done } # ]]] @@ -2150,6 +2163,7 @@ print -- "\nAvailable ice-modifiers:\n\n${ice_order[*]}" +zi-log "Zinit's binary directory: {file}${ZINIT[BIN_DIR]}{rst}" +zi-log "Plugin directory: {file}${ZINIT[PLUGINS_DIR]}{rst}" +zi-log "Completions directory: {file}${ZINIT[COMPLETIONS_DIR]}{rst}" + +zi-log "ZPFX directory: {file}${ZINIT[ZPFX]:-$ZPFX}{rst}" # Without _zlocal/zinit +zi-log "Loaded plugins: {num}$(( ${#ZINIT_REGISTERED_PLUGINS[@]} - 1 )){rst}" diff --git a/zinit-install.zsh b/zinit-install.zsh index 8d8679ad8..20bf1e869 100644 --- a/zinit-install.zsh +++ b/zinit-install.zsh @@ -341,9 +341,8 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { if [[ $tpe != tarball ]] { if [[ -z $update ]] { .zinit-any-colorify-as-uspl2 "$user" "$plugin" - local pid_hl='{pid}' id_msg_part=" (at label{ehi}:{rst} {id-as}$id_as{rst}{…})" - (( $+ICE[pack] )) && local infix_m="({b}{ice}pack{apo}''{rst}) " - +zi-log "{nl}Downloading $infix_m{pid}$user${user:+/}$plugin{…}${${${id_as:#$user/$plugin}}:+$id_msg_part}" + local pid_hl='{pid}' id_msg_part=" (at label: {id-as}$id_as{rst})" + +zi-log "{nl}{i} Downloading {b}{file}$user${user:+/}$plugin{rst} ${${${id_as:#$user/$plugin}}:+$id_msg_part}{rst}" } local site @@ -378,7 +377,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { { local old_version="$(<$local_path/._zinit/is_release${count:#1})"; } 2>/dev/null old_version=${old_version/(#b)(\/[^\/]##)(#c4,4)\/([^\/]##)*/${match[2]}} } - +zi-log "(Requesting \`${REPLY:t}'${version:+, version $version}{…}${old_version:+ Current version: $old_version.})" + +zi-log "{m} Requesting ${REPLY:t} ${version:+, version $version} ${old_version:+ Current version: $old_version.}{rst}" if { ! .zinit-download-file-stdout "$url" 0 1 >! "${REPLY:t}" } { if { ! .zinit-download-file-stdout "$url" 1 1 >! "${REPLY:t}" } { command rm -f "${REPLY:t}" @@ -830,7 +829,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { .zinit-compute-ice "$id_as" "pack" \ ICE plugin_dir filename is_snippet || return 1 - # when from"gh-r" ice set, skip compile unless compile ice is set + # when from"gh-r" ice set, skip compile unless compile ice is set if [[ ${ICE[from]} = gh-r ]] && (( ${+ICE[compile]} == 0 )); then +zi-log '{dbg} from"gh-r" detected, skipping compile' return 0 @@ -992,7 +991,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { ( () { setopt localoptions noautopushd; builtin cd -q "$local_dir"; } || return 4 - (( !OPTS[opt_-q,--quiet] )) && +zi-log "Downloading {apo}\`{url}$sname{apo}\`{rst}${${ICE[svn]+" (with Subversion)"}:-" (with curl, wget, lftp)"}{…}" + (( !OPTS[opt_-q,--quiet] )) && +zi-log "{i} Downloading {file}$sname{rst} ${${ICE[svn]+" (with Subversion)"}:-" (with curl, wget, lftp)"}{rst}" if (( ${+ICE[svn]} )) { if [[ $update = -u ]] { @@ -1503,7 +1502,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { _sys='pc-windows-gnu' ;; (*) - +zi-log "{info}[{pre}gh-r{info}]{error} Unsupported OS: {obj}${_os}{rst}" + +zi-log "{e} {b}gh-r{rst}Unsupported OS: {obj}$_os{rst}" ;; esac case "$_cpu" in @@ -1520,7 +1519,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { _os=${_os}eabihf ;; (*) - +zi-log "{info}[{pre}ziextract{info}]{error} Unsupported CPU: {obj}$_cpu{rst}" + +zi-log "{e} {b}gh-r{rst}Unsupported CPU: {obj}$_cpu{rst}" ;; esac echo "${_sys};${_cpu};${_os}" @@ -1535,7 +1534,6 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { local plugin="$2" urlpart="$3" user="$1" local -a bpicks filtered init_list list parts parts=(${(@s:;:)$(.zi::get-architecture)}) - # +zi-log "{info}[{pre}gh-r{info}]{rst} filters -> {glob}${(@)parts}{rst}" if [[ -z $urlpart ]]; then local tag_version=${ICE[ver]} if [[ -z $tag_version ]]; then @@ -1558,18 +1556,16 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { if [[ -n $bpick ]]; then list=( ${(M)list[@]:#(#i)*/$~bpick} ) if (( !$#list )); then - +zi-log "{info}[{pre}gh-r{info}] {error}Error{rst}: {ice}bpick{rst} ice found no release assets{rst}. To fix, modify the {ice}bpick{rst} glob pattern {glob}${bpick}{rst}" + +zi-log "{e} {b}gh-r{rst}: {ice}bpick{rst} ice found no release assets To fix, modify the {ice}bpick{rst} glob pattern {glob}$bpick{rst}" fi + else + local junk="(386|md5|sig|asc|txt|vsix|sum|sha256*|pkg|([\.]apk|deb|json|rpm|sh))" + filtered=( ${list[@]:#(#i)*${~junk}*} ) && (( $#filtered > 0 )) && list=( ${filtered[@]} ) fi - local junk="(md5|sig|asc|txt|vsix|sum|sha256*|pkg|.(apk|deb|json|rpm|sh(#e)))" - filtered=( ${list[@]:#(#i)*${~junk}*} ) && (( $#filtered > 0 )) && list=( ${filtered[@]} ) - local -a array=( $(print -rm "*(${MACHTYPE}|${VENDOR}|)*~^*(${parts[1]}|${(L)$(uname)})*" $list[@]) ) (( ${#array} > 0 )) && list=( ${array[@]} ) - +zi-log -- "{dbg} filtered ${#filtered} to ${#array} release assets" - +zi-log -- "{dbg}${(@pj:\n - :)list[1,2]}{nl}" for part in "${parts[@]}"; do if (( $#list > 1 )); then filtered=( ${(M)list[@]:#(#i)*${~part}*} ) && (( $#filtered > 0 )) && list=( ${filtered[@]} ) @@ -1581,7 +1577,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { if (( $#list > 1 )) { filtered=( ${list[@]:#(#i)*.(sha[[:digit:]]#|asc)} ) && (( $#filtered > 0 )) && list=( ${filtered[@]} ); } if (( !$#list )); then - +zi-log "{nl}{info}[{pre}gh-r{info}] {error}Error{rst}: No GitHub release assets found for {glob}${tag_version}{rst}" + +zi-log "{e} {b}gh-r{rst}: No GitHub release assets found for {glob}$tag_version{rst}" return 1 fi reply+=( "${list[1]}" ) @@ -2004,7 +2000,7 @@ zpextract() { # Download the package # - +zi-log "{info}Downloading{ehi}: {file}${url:t}{info}{…}{rst}" + +zi-log "{nl}{i} Downloading {b}{file}${url:t}{rst}" retry=2 while (( retry -- )) { integer retval=0 @@ -2063,81 +2059,6 @@ zimv() { if [[ $1 = (-d|--dir) ]] { dir=$2; shift 2; } zicp --mv ${dir:+--dir} $dir "$@" } # ]]] -# FUNCTION: .zinit-configure-run-autoconf [[[ -# Called if # passed to configure ice or no ./configure found -# Runs autoconf, autoreconf, and autogen.sh -.zinit-configure-run-autoconf() { - local dir=$1 flags=$2 - integer q - local msg="{pre} ({flag}#{pre} flag given){…}" msg_="{pre}{…}" - # Custom script - if [[ -f $dir/autogen.sh ]]; then - q=1 - m {pre}Running {cmd}./autogen.sh${${${(M)flags:#*\#*}:+$msg}:-$msg_} - .zinit-countdown ./autogen.sh && \ - ( - cd -q $dir - chmod +x ./autogen.sh - ./autogen.sh - ) - # Autoreconf only if available in PATH - elif [[ -f $dir/configure && -f $dir/configure.ac && \ - $+commands[autoreconf] = 1 ]]; then - q=1 - m {pre}Running {cmd}autoreconf {opt}-f${${${(M)flags:#*\#*}:+$msg}:-$msg_} - .zinit-countdown autoreconf\ -f\ -i\ … && \ - ( - cd -q $dir - rm -f aclocal.m4 - aclocal -I m4 --force - libtoolize --copy --force - autoreconf -f -i -I m4 - ) - # Manual reproduction of autoreconf run - elif [[ -f $dir/configure && -f $dir/configure.ac ]]; then - q=1 - m {pre}Running {cmd}aclocal{pre}, {cmd}autoconf{pre} and {cmd}automake\ -${${${(M)flags:#*\#*}:+$msg}:-$msg_} - .zinit-countdown aclocal,\ autoconf,\ automake && \ - ( - cd -q $dir - rm -f aclocal.m4 - aclocal -I m4 --force - libtoolize --copy --force - aclocal -I m4 --force - autoconf -I m4 -f - autoheader -I m4 -f - automake --add-missing -c --force-missing - ) - # Only autoconf if no existing ./configure - elif [[ ! -f $dir/configure && -f $dir/configure.ac ]]; then - q=1 - m {pre}Running {cmd}autoconf {opt}-f${${${(M)flags:#*\#*}:+$msg}:-$msg_} - .zinit-countdown autoconf\ -f && \ - ( - cd -q $dir - autoconf -f -I m4 - ) - elif [[ $flags == *\#* ]]; then - m {ehi}WARNING:{error}: No {cmd}autogen.sh{error} nor {file}configure.ac \ - {error}on disk while the {flag}\# \ - {error}flag given to the {ice}configure{apo}\'\'{error} ice, skipping \ - further {cmd}./configure{error}-generation related actions{…} - ((1)) - fi - if [[ ! -f $dir/configure ]]; then - if (( q )); then - m {error}WARNING:some input files existed \({file}configure.ac{error}, \ - etc.\) however running {cmd}Autotools{error} didn\'t yield a \ - {cmd}./configure{error} script, meaning that it won\'t be run\! \ - Please check if you have packages such as {pkg}autoconf{error}, \ - {pkg}autmake{error} and similar installed. - else - # No output – lacking both configure.ac and configure → a no-op - : - fi - fi -} # ]]] # FUNCTION: ∞zinit-reset-hook [[[ ∞zinit-reset-hook() { # File @@ -2223,10 +2144,52 @@ ${${${(M)flags:#*\#*}:+$msg}:-$msg_} ZINIT[-r/--reset-opt-hook-has-been-run]=1 } } # ]]] + +# FUNCTION: ∞zinit-configure-base-hook [[[ +# A base common implementation of the configure ice +∞zinit-configure-base-hook () { + emulate -L zsh + setopt extendedglob + if [[ "$1" = plugin ]]; then + local dir="${5#%}" hook="$6" subtype="$7" ex="$8" + else + local dir="${4#%}" hook="$5" subtype="$6" ex="$7" + fi + local flags configure eflags aflags ice='{b}configure{rst}:' + configure=${ICE[configure]} + @zinit-substitute configure + (( ${+ICE[configure]} )) || return 0 + flags=${(M)configure##[smc0\!\#]##} + configure=${configure##$flags([[:space:]]##|(#e))} + eflags=${(SM)flags##[\!]##} + aflags=${(SM)flags##[smc0]##} + [[ $eflags == $ex ]] || return 0 + typeset -aU configure_opt=(${(@s; ;)configure}) + configure_opt+=("--prefix ${ZINIT[ZPFX]}") + { + builtin cd -- "$dir" || return 1 + if [[ ! -e configure || ! -e Makefile ]]; then + +zi-log "{m} ${ice} Attempting to generate configure script... " + local c + for c in "[[ -e autogen.sh ]] && ./autogen.sh" "[[ -n *.a[mc](#qN.) ]] && autoreconf -ifm" "git clean -fxd; aclocal --force; autoconf --force; automake --add-missing --copy --force-missing"; do + +zi-log -PrD "{dbg} ${ice} {faint}${c}{rst}" + eval "${c}" 2>/dev/null >&2 + if [[ -f configure ]]; then + +zi-log "{dbg} ${ice} {faint}./configure $(builtin print -PDn -- ${(Ds; ;)configure_opt[@]//prefix /prefix=}){rst}" + eval "./configure ${(S)configure_opt[@]//prefix /prefix=}" 2>/dev/null 1>&2 + if [[ $? -eq 0 || -f Makefile ]]; then + +zi-log "{m} ${ice} Successfully configured Makefile" + break + else + +zi-log "{e} ${ice} Failed project configuration" + fi + fi + done + fi + } + return 0 +} # ]]] # FUNCTION: ∞zinit-configure-e-hook [[[ -# The !-version of configure'' ice. Runs in between -# of make'!!' and make'!'. Configure naturally runs -# before make. ∞zinit-configure-e-hook() { ∞zinit-configure-base-hook "$@" "!" } # ]]] @@ -2235,148 +2198,115 @@ ${${${(M)flags:#*\#*}:+$msg}:-$msg_} # of make'!' and make''. Configure script naturally runs # before make. ∞zinit-configure-hook() { - ∞zinit-configure-base-hook "$@" + ∞zinit-configure-base-hook "$@" "" } # ]]] -# FUNCTION: ∞zinit-configure-base-hook [[[ -# A base common implementation of configure'', as all -# the starting steps are rigid and the same in all -# hooks, hence the idea. TODO: use in make'' and other -# places. -∞zinit-configure-base-hook() { - [[ "$1" = plugin ]] && \ - local dir="${5#%}" hook="$6" subtype="$7" ex="$8" || \ - local dir="${4#%}" hook="$5" subtype="$6" ex="$7" - emulate -L zsh -o extendedglob - - local configure=${ICE[configure]} - @zinit-substitute configure - - # c-cmake, s-scons, m-meson, 0-default (configure) - local flags=${(M)configure##[smc0\!\#]##} - configure=${configure##$flags([[:space:]]##|(#e))} - (( ${+ICE[configure]} )) || return 0 - # !-only flags - local eflags=${(SM)flags##[\!]##} aflags=${(SM)flags##[smc0]##} - [[ $eflags == $ex ]] || return 0 - - # Conditionally run autogen.sh/autoconf/aclocal/etc. to - # see if we got an output ./configure file (or preexisting - # if no autotools have been resolved to run from the optional - # # flag and the .ac/.m4 input files) ready to run - [[ $flags == *\#* || ! -f $dir/configure ]] && - .zinit-configure-run-autoconf "$dir" $flags - - if [[ $flags == (#b)*([^smc0\!\#]##)* || ${flags//[\!\#]##/} == (#b)(([smc0](#c2,))) ]]; then - m {error}ERROR: improper ${match[2]:+\(multiple of s,m,c\?\)} flag\(s\) \({flag}${match[1]}{error}\) \ - given, skipping further build system actions processing{…} - return 1 +# FUNCTION: ∞zinit-make-base-hook [[[ +# A base common implementation of the make ice +∞zinit-make-base-hook () { + emulate -L zsh + setopt extendedglob + [[ -z $ICE[make] ]] && return 0 + if [[ "$1" = plugin ]]; then + local dir="${5#%}" hook="$6" subtype="$7" ex="$8" + else + local dir="${4#%}" hook="$5" subtype="$6" ex="$7" + fi + local make=${ICE[make]} ice='{b}make{rst}:' + @zinit-substitute make + (( ${+ICE[make]} )) || return 0 + local eflags=${(M)make##[\!]##} + make=${make##$eflags} + [[ $ex == $eflags ]] || return 0 + local make_prefix='prefix' + if grep -w -- "PREFIX =" ${dir}/[Mm]akefile >/dev/null; then + make_prefix="PREFIX" fi - local -a files=( $dir/CMakeLists.txt(N) $dir/*/CMakeLists.txt(N) ) - if [[ $#files -gt 0 && -z $aflags || $flags == [^a-z0]#c[^a-z0]# ]]; then - if (( ${+commands[cmake]} )); then - command mkdir -p $dir/_build-zinit - m {pre}Running {cmd}cmake{pre} ${${${${#files}:#0}:+for \ - its found {file}CMakeLists.txt{pre} input file{…}}:-\ -because {flag}c{pre} flag given} - .zinit-countdown cmake && \ - ( cd -q $dir/_build-zinit; cmake -DCMAKE_INSTALL_PREFIX=$ZPFX .. ${(@s; ;)configure} ) - else - m {error}Error: no {cmd}cmake{error} binary found and \ - ${${${${#files}:#0}:+its input file exists \ - \({file}CMakeLists.txt{error}\)}:-and {flag}c{error} \ - flag given}! Skipping{…} - fi + local src=($dir/[Cc][Mm]ake*(N.om[1])) + if (( $#src )); then + +zi-log "{m} ${ice} Detected Cmake project, using CMAKE_INSTALL_PREFIX={file}\$ZPFX{rst}" + make_prefix="CMAKE_INSTALL_PREFIX" + else + +zi-log -ru2 -- "{dbg} ${dir:t}: No Cmake files found in ${dir}" fi - local -a files=( $dir/SConstruct(N) $dir/*/SConstruct(N) ) - if [[ $#files -gt 0 && -z $aflags || $flags == [^a-z0]#s[^a-z0]# ]]; then - if (( ${+commands[scons]} )); then - m {pre}Running {cmd}scons{pre} for its found {file}SConstruct{pre} input file{…} - .zinit-countdown scons && \ - ( cd $dir; scons RELEASE=yes --prefix=$ZPFX ${(@s; ;)configure} ) - else - m {error}Error: no {cmd}scons{error} binary found and \ - ${${${${#files}:#0}:+its input file exists \ - ({file}SConstruct{error})}:-and {flag}s{error} \ - flag given}! Skipping{…} - fi + local prefix="${ZINIT[ZPFX]}" + if [[ -n OPTS[opt_-q,--quiet] || -n ${ZINIT[DEBUG]:#1} ]]; then + +zi-log "{dbg} ${ice} setting quiet mode" + local quiet='2>/dev/null 1>&2' fi - local -a files=( $dir/meson.build(N) $dir/*/meson.build(N) ) - if [[ $#files -gt 0 && -z $aflags || $flags == [^a-z0]#m[^a-z0]# ]]; then - if (( ${+commands[meson]} )); then - m {pre}Running {cmd}meson setup{pre} ${${${${#files}:#0}:+\ -for its found {file}meson.build{pre} input file}:-because {flag}m{pre} \ - flag given}{…} - .zinit-countdown meson\ setup && \ - ( cd $dir; command meson setup --prefix=$ZPFX _build-zinit ${(@s; ;)configure} ) - else - m {error}Error: no {cmd}meson{error} binary found and \ - ${${${${#files}:#0}:+its input file exists \ - ({file}meson.build{error})}:-{flag}m{error} \ - flag given}! Skipping{…} + local -i ret=0 + { + build="command make -C ${dir} --jobs" + +zi-log "{m} ${ice} {faint}${(Ds; ;)build} $make_prefix=$(builtin print -Pnf '%s' ${(D)ZINIT[ZPFX]}){rst}" + +zi-log "{dbg} ${ice} eval ${build} $make_prefix=$prefix 2>/dev/null 1>&2" + eval "${build} $make_prefix=$prefix" 2>/dev/null 1>&2 + ret=$? + } always { + if (( ret )); then + +zi-log "{w} ${ice} build returned {num}${ret}{rst}" fi - fi - if [[ -f $dir/configure && -z $aflags || $flags == [^a-z0]#0[^a-z0]# ]]; then - m {pre}Running {cmd}./configure {opt}--prefix{meta}={b}{dir}$ZPFX{nb}{…} - .zinit-countdown ./configure && \ - ( - cd -q $dir - chmod +x ./configure - ./configure --prefix=$ZPFX ${(@s; ;)configure} - ) - fi -} # ]]] -# FUNCTION: ∞zinit-make-ee-hook [[[ -∞zinit-make-ee-hook() { - ∞zinit-make-base-hook "$@" "!!" + (( TRY_BLOCK_ERROR = 0 )) + } + { + install="${build} ${make}" + +zi-log "{m} ${ice} ${(Ds; ;)build} $make_prefix=$(builtin print -Pnf '%s' ${(D)ZINIT[ZPFX]}) ${make} {rst}" + +zi-log "{dbg} ${ice} eval ${build} $make_prefix=$prefix ${make} 2>/dev/null 1>&2" + eval "${(s; ;)install} $make_prefix=$prefix" 2>/dev/null 1>&2 + ret=$? + } always { + if (( ret )); then + +zi-log "{w} ${ice} install returned {num}${ret}{rst}" + fi + (( TRY_BLOCK_ERROR = 0 )) + } + return $ret } # ]]] # FUNCTION: ∞zinit-make-e-hook [[[ ∞zinit-make-e-hook() { ∞zinit-make-base-hook "$@" "!" } # ]]] +# FUNCTION: ∞zinit-make-ee-hook [[[ +∞zinit-make-ee-hook() { + ∞zinit-make-base-hook "$@" "!!" +} # ]]] # FUNCTION: ∞zinit-make-hook [[[ ∞zinit-make-hook() { ∞zinit-make-base-hook "$@" "" } # ]]] -# FUNCTION: ∞zinit-make-base-hook [[[ -∞zinit-make-base-hook() { - [[ "$1" = plugin ]] && \ - local dir="${5#%}" hook="$6" subtype="$7" ex="$8" || \ - local dir="${4#%}" hook="$5" subtype="$6" ex="$7" - - local make=${ICE[make]} - @zinit-substitute make - - # Save preceding ! only - local eflags=${(M)make##[\!]##} - make=${make##$eflags} - (( ${+ICE[make]} )) || return 0 - [[ $ex == $eflags ]] || return 0 - # For meson and cmake - [[ -d $dir/_build-zinit ]] && dir+=/_build-zinit - - # Run either `make` or `meson compile` - if [[ -f $dir/Makefile ]]; then - m {pre}Running {apo}\`{cmd}make{opt} ${(@s; ;)make}{apo}\`{pre}{…} - .zinit-countdown make && - command make -C "$dir" ${(@s; ;)make} - elif [[ -f $dir/build.ninja ]]; then - m {pre}Running {apo}\`{cmd}meson{opt} compile{apo}\`{pre}{…} - .zinit-countdown meson\ compile && - meson compile -C "$dir" - [[ $make == ([[:space:]]|(#s))install([[:space:]]|(#e)) ]] && - { - m {pre}Running {apo}\`{cmd}meson{opt} ${(@s; ;)make}{apo}\`{pre}{…} - .zinit-countdown meson\ ${(@s; ;)make} && - meson ${(@s; ;)make} -C "$dir" - } +# FUNCTION: __zinit-cmake-base-hook [[[ +# A base common implementation of the cmake ice +__zinit-cmake-base-hook () { + emulate -L zsh + setopt extended_glob + (( ${+ICE[cmake]} )) || return 0 + if (( ! ${+commands[cmake]} )); then + +zi-log "{e} {cmd}cmake{rst} required to use {ice}cmake{rst} ice" + return 0 + fi + if [[ "$1" = plugin ]]; then + local dir="${5#%}" hook="$6" subtype="$7" ex="$8" else - m {error}ERROR: No {file}Makefile{error} nor {cmd}meson{error} \ - build dir found, {cmd}make{error}/{cmd}meson{error} isn\'t run\! + local dir="${4#%}" hook="$5" subtype="$6" ex="$7" fi + (( OPTS[opt_-q,--quiet] || ZINIT[DEBUG] )) && local QUIET='2>/dev/null 1>&2' + local c ret=0 ice='{b}cmake{rst}:' + for c in "-S ${dir} -B ${dir}/build -DCMAKE_BUILD_TYPE=Release --install-prefix ${ZINIT[ZPFX]} ${QUIET}" "--build ${dir}/build --parallel $(nproc) ${QUIET}" "--install ${dir}/build ${QUIET}"; do + +zi-log "{m} ${ice} {faint}cmake ${(Ds; ;)c} {rst}" + eval "command cmake ${c}" 2> /dev/null >&2 + if (( $? )); then + +zi-log "{e} ${ice} Failure cmake ${c}{rst}" + ret=$? + fi + done + return $? +} # ]]] +# FUNCTION: +zinit-cmake-hook [[[ ++zinit-cmake-hook() { + __zinit-cmake-base-hook "$@" } # ]]] + # FUNCTION: ∞zinit-atclone-hook [[[ ∞zinit-atclone-hook() { [[ "$1" = plugin ]] && \ diff --git a/zinit.zsh b/zinit.zsh index cc536fccc..e4ed3d7e1 100644 --- a/zinit.zsh +++ b/zinit.zsh @@ -62,6 +62,8 @@ if [[ -z ${ZINIT[HOME_DIR]} ]]; then fi fi + + if [[ -z ${ZINIT[LIST_COMMAND]} ]]; then if (( ${+commands[exa]} )); then ZINIT[LIST_COMMAND]='exa --color=always --tree --icons -L3' @@ -75,8 +77,8 @@ fi ZINIT[ice-list]="\ \!bash|\!csh|\!ksh|\!sh|\ aliases|as|atclone|atdelete|atinit|atload|atpull|autoload|\ -bash|binary|bindmap|blockf|bpick|\ -cloneonly|cloneopts|compile|completions|configure|countdown|cp|csh|\ +bash|binary|bindmap|blockf|bpick|build|\ +cloneonly|cloneopts|cmake|compile|completions|configure|countdown|cp|csh|\ debug|depth|\ extract|\ from|git|\ @@ -97,7 +99,7 @@ ZINIT[nval-ice-list]="\ \!bash|\!csh|\!ksh|\!sh|\ aliases|\ bash|binary|blockf|\ -cloneonly|cloneopts|countdown|csh|\ +cloneonly|cloneopts|cmake|configure|countdown|csh|\ debug|\ git|\ is-snippet|\ @@ -133,16 +135,19 @@ zstatus" # Can be customized. : ${ZINIT[COMPLETIONS_DIR]:=${ZINIT[HOME_DIR]}/completions} : ${ZINIT[MODULE_DIR]:=${ZINIT[HOME_DIR]}/module} -: ${ZINIT[PACKAGES_REPO]:=zdharma-continuum/zinit-packages} : ${ZINIT[PACKAGES_BRANCH]:=HEAD} +: ${ZINIT[PACKAGES_REPO]:=zdharma-continuum/zinit-packages} : ${ZINIT[PLUGINS_DIR]:=${ZINIT[HOME_DIR]}/plugins} +: ${ZINIT[POLARIS_DIR]:=${ZINIT[HOME_DIR]}/polaris} : ${ZINIT[SERVICES_DIR]:=${ZINIT[HOME_DIR]}/services} : ${ZINIT[SNIPPETS_DIR]:=${ZINIT[HOME_DIR]}/snippets} +: ${ZINIT[ZPFX]:=${ZINIT[HOME_DIR]}/polaris} typeset -g ZPFX -: ${ZPFX:=${ZINIT[HOME_DIR]}/polaris} +: ${ZPFX:=${ZINIT[ZPFX]}} : ${ZINIT[ALIASES_OPT]::=${${options[aliases]:#off}:+1}} : ${ZINIT[MAN_DIR]:=${ZPFX}/man} + ZINIT[PLUGINS_DIR]=${~ZINIT[PLUGINS_DIR]} ZINIT[COMPLETIONS_DIR]=${~ZINIT[COMPLETIONS_DIR]} ZINIT[SNIPPETS_DIR]=${~ZINIT[SNIPPETS_DIR]} ZINIT[SERVICES_DIR]=${~ZINIT[SERVICES_DIR]} export ZPFX=${~ZPFX} ZSH_CACHE_DIR="${ZSH_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/zinit}" \ @@ -150,6 +155,11 @@ export ZPFX=${~ZPFX} ZSH_CACHE_DIR="${ZSH_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.ca [[ -z ${path[(re)$ZPFX/bin]} ]] && [[ -d "$ZPFX/bin" ]] && path=( "$ZPFX/bin" "${path[@]}" ) [[ -z ${path[(re)$ZPFX/sbin]} ]] && [[ -d "$ZPFX/sbin" ]] && path=( "$ZPFX/sbin" "${path[@]}" ) +hash -f +hash -d zinit=${ZINIT[HOME_DIR]} +hash -d plugins=${ZINIT[PLUGINS_DIR]} +hash -d zpfx=${ZINIT[HOME_DIR]}/polaris + # Add completions directory to fpath. [[ -z ${fpath[(re)${ZINIT[COMPLETIONS_DIR]}]} ]] && fpath=( "${ZINIT[COMPLETIONS_DIR]}" "${fpath[@]}" ) @@ -215,10 +225,12 @@ if [[ -z $SOURCED && ( ${+terminfo} -eq 1 && -n ${terminfo[colors]} ) || ( ${+te col-ehi $'\e[1m\e[38;5;210m' col-meta $'\e[38;5;57m' col-pname $'\e[1;4m\e[32m' col-var $'\e[38;5;81m' col-error $'\e[1m\e[38;5;204m' col-meta2 $'\e[38;5;147m' col-pre $'\e[38;5;135m' col-version $'\e[3;38;5;87m' col-failure $'\e[38;5;204m' col-msg $'\e[0m' col-profile $'\e[38;5;148m' col-warn $'\e[38;5;214m' - - col-i $'\e[1m\e[38;5;82m'"==>"$'\e[0m' col-e $'\e[1m\e[38;5;204m'"Error: "$'\e[0m' - col-m $'\e[1m\e[38;5;135m'"==>"$'\e[0m' col-w $'\e[1;38;5;214m'"Warning: "$'\e[0m' - col-dbg $'\e[2m\e[38;47;108m'"[debug]"$'\e[0m' + + col-dbg $'\e[2m\e[38;47;107m'"[debug]"$'\e[0m' + col-e $'\e[1m\e[38;5;204m'"Error"$'\e[0m'":" + col-i $'\e[1m\e[38;5;82m'"==>"$'\e[0m' + col-m $'\e[1m\e[38;5;135m'"==>"$'\e[0m' + col-w $'\e[1m\e[38;5;214m'"Warning"$'\e[0m'":" col--… "${${${(M)LANG:#*UTF-8*}:+⋯⋯}:-···}" col-lr "${${${(M)LANG:#*UTF-8*}:+↔}:-"«-»"}" col-ndsh "${${${(M)LANG:#*UTF-8*}:+–}:-}" col-… "${${${(M)LANG:#*UTF-8*}:+…}:-...}" @@ -1264,7 +1276,7 @@ builtin setopt noaliases # For compaudit. command chmod go-w "${ZINIT[HOME_DIR]}" # Also set up */bin and ZPFX in general. - command mkdir 2>/dev/null -p $ZPFX/bin + command mkdir -p "${ZPFX:-ZINIT[HOME_DIR]/polaris}/bin" } [[ ! -d ${ZINIT[PLUGINS_DIR]}/_local---zinit ]] && { command rm -rf "${ZINIT[PLUGINS_DIR]:-${TMPDIR:-/tmp}/132bcaCAB}/_local---zplugin" @@ -1273,7 +1285,7 @@ builtin setopt noaliases command ln -s "${ZINIT[BIN_DIR]}/_zinit" "${ZINIT[PLUGINS_DIR]}/_local---zinit" # Also set up */bin and ZPFX in general. - command mkdir 2>/dev/null -p $ZPFX/bin + command mkdir -p "${ZPFX:-ZINIT[HOME_DIR]/polaris}/bin" (( ${+functions[.zinit-setup-plugin-dir]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-install.zsh" || return 1 (( ${+functions[.zinit-confirm]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-autoload.zsh" || return 1 @@ -1289,7 +1301,7 @@ builtin setopt noaliases command ln -s "${ZINIT[PLUGINS_DIR]}/_local---zinit/_zinit" "${ZINIT[COMPLETIONS_DIR]}" # Also set up */bin and ZPFX in general. - command mkdir 2>/dev/null -p $ZPFX/bin + command mkdir -p "${ZPFX:-ZINIT[HOME_DIR]/polaris}/bin" (( ${+functions[.zinit-setup-plugin-dir]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-install.zsh" || return 1 .zinit-compinit &>/dev/null @@ -1304,7 +1316,7 @@ builtin setopt noaliases command chmod go-w "${ZINIT[SERVICES_DIR]}" # Also set up */bin and ZPFX in general. - command mkdir 2>/dev/null -p $ZPFX/bin + command mkdir -p "${ZPFX:-ZINIT[HOME_DIR]/polaris}/bin" } [[ ! -d ${~ZINIT[MAN_DIR]}/man9 ]] && { # Create ZINIT[MAN_DIR]/man{1..9} @@ -1972,15 +1984,6 @@ builtin setopt noaliases builtin zle -F "$THEFD" +zinit-deploy-message } # ]]] -# FUNCTION: .zinit-formatter-dbg [[[ -.zinit-formatter-dbg() { - builtin emulate -L zsh -o extendedglob - REPLY= - if (( ZINIT[DEBUG] )); then - REPLY="$ZINIT[col-dbg]$1" - fi -} # ]]] - # FUNCTION: .zinit-formatter-auto [[[ .zinit-formatter-auto() { emulate -L zsh -o extendedglob -o warncreateglobal -o typesetsilent @@ -2166,6 +2169,10 @@ builtin setopt noaliases ZINIT[__last-formatter-code]= msg=${${(j: :)${@:#--}}//\%/%%} + if [[ -z $ZINIT[DEBUG] ]] && [[ "$msg" = (#s){dbg}* ]]; then + return + fi + # First try a dedicated formatter, marking its empty output with ←→, then # the general formatter and in the end filter-out the ←→ from the message. msg=${${msg//(#b)(([\\]|(%F))([\{]([^\}]##)[\}])|([\{]([^\}]##)[\}])([^\%\{\\]#))/\ @@ -2252,19 +2259,27 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→} # Parses ICE specification, puts the result into ICE global hash. # The ice-spec is valid for next command only (i.e. it "melts"), but # it can then stick to plugin and activate e.g. at update. -.zinit-ice() { +.zinit-ice () { builtin setopt localoptions noksharrays extendedglob warncreateglobal typesetsilent noshortloops integer retval local bit exts="${(j:|:)${(@)${(@Akons:|:)${ZINIT_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}}" for bit; do - [[ $bit = (#b)(--|)(${~ZINIT[ice-list]}${~exts})(*) ]] && \ - ZINIT_ICES[${match[2]}]+="${ZINIT_ICES[${match[2]}]:+;}${match[3]#(:|=)}" || \ - break + [[ $bit = (#b)(--|)(${~ZINIT[ice-list]}${~exts})(*) ]] && ZINIT_ICES[${match[2]}]+="${ZINIT_ICES[${match[2]}]:+;}${match[3]#(:|=)}" || break retval+=1 done [[ ${ZINIT_ICES[as]} = program ]] && ZINIT_ICES[as]=command [[ -n ${ZINIT_ICES[on-update-of]} ]] && ZINIT_ICES[subscribe]="${ZINIT_ICES[subscribe]:-${ZINIT_ICES[on-update-of]}}" [[ -n ${ZINIT_ICES[pick]} ]] && ZINIT_ICES[pick]="${ZINIT_ICES[pick]//\$ZPFX/${ZPFX%/}}" + if (( $+ZINIT_ICES[build] )); then + +zi-log -- "{dbg} {ice}build{rst}: setting configure & make ices" + ZINIT_ICES[configure]= + ZINIT_ICES[make]= + fi + if (( $+ZINIT_ICES[configure] || $+ZINIT_ICES[cmake] || $+ZINIT_ICES[make] )); then + ZINIT_ICES[null]= + fi + (( $+ZINIT_ICES[configure] )) && ZINIT_ICES[configure]=${ZINIT_ICES[configure]:---quiet} + (( $+ZINIT_ICES[make] )) && ZINIT_ICES[make]=${ZINIT_ICES[make]:-install} return retval } # ]]] # FUNCTION: .zinit-pack-ice [[[ @@ -3274,6 +3289,7 @@ if [[ -e ${${ZINIT[BIN_DIR]}}/zmodules/Src/zdharma/zplugin.so ]] { @zinit-register-hook "configure''" hook:no-e-\!atpull-post ∞zinit-configure-hook @zinit-register-hook "atpull" hook:no-e-\!atpull-post ∞zinit-atpull-hook @zinit-register-hook "make''" hook:no-e-\!atpull-post ∞zinit-make-hook +@zinit-register-hook "cmake''" hook:no-e-\!atpull-post +zinit-cmake-hook # atpull-post. @zinit-register-hook "compile-plugin" hook:atpull-post ∞zinit-compile-plugin-hook @zinit-register-hook "ps-on-update" hook:%atpull-post ∞zinit-ps-on-update-hook @@ -3290,6 +3306,7 @@ if [[ -e ${${ZINIT[BIN_DIR]}}/zmodules/Src/zdharma/zplugin.so ]] { @zinit-register-hook "configure''" hook:\!atclone-post ∞zinit-configure-hook @zinit-register-hook "atclone" hook:\!atclone-post ∞zinit-atclone-hook @zinit-register-hook "make''" hook:\!atclone-post ∞zinit-make-hook +@zinit-register-hook "cmake''" hook:\!atclone-post +zinit-cmake-hook # atclone-post. @zinit-register-hook "compile-plugin" hook:atclone-post ∞zinit-compile-plugin-hook