feat: upgrade elvish to 0.17.0 (#1159)

* feat: upgrade elvish to 0.17.0
* Remove || and fix array slice
* Update elvish config path
* Tests use new path
* Escape $ in bats
* Fix legacy assignment in test
This commit is contained in:
Bruno Roque 2022-02-11 23:19:55 +01:00 committed by GitHub
parent 2a538fe631
commit 824550ed20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 114 additions and 114 deletions

View File

@ -38,11 +38,11 @@ jobs:
sudo apt-get -y install fish curl
# Download elvish binary and add to path
curl https://dl.elv.sh/linux-amd64/elvish-v0.16.3.tar.gz -o elvish-v0.16.3.tar.gz
tar xzf elvish-v0.16.3.tar.gz
rm elvish-v0.16.3.tar.gz
curl https://dl.elv.sh/linux-amd64/elvish-v0.17.0.tar.gz -o elvish-v0.17.0.tar.gz
tar xzf elvish-v0.17.0.tar.gz
rm elvish-v0.17.0.tar.gz
mkdir -p "$HOME/bin"
mv elvish-v0.16.3 "$HOME/bin/elvish"
mv elvish-v0.17.0 "$HOME/bin/elvish"
echo "$HOME/bin" >>"$GITHUB_PATH"
- name: Install bats

View File

@ -5,21 +5,21 @@ use path
var asdf_dir = $E:HOME'/.asdf'
if (and (has-env ASDF_DIR) (!=s $E:ASDF_DIR '')) {
asdf_dir = $E:ASDF_DIR
set asdf_dir = $E:ASDF_DIR
} else {
set-env ASDF_DIR $asdf_dir
}
var asdf_data_dir = $asdf_dir
if (and (has-env ASDF_DATA_DIR) (!=s $E:ASDF_DATA_DIR '')) {
asdf_data_dir = $E:ASDF_DATA_DIR
set asdf_data_dir = $E:ASDF_DATA_DIR
}
# Add function wrapper so we can export variables
fn asdf [command @args]{
fn asdf {|command @args|
if (==s $command 'shell') {
# set environment variables
parts = [($asdf_dir'/bin/asdf' export-shell-version elvish $@args)]
var parts = [($asdf_dir'/bin/asdf' export-shell-version elvish $@args)]
if (==s $parts[0] 'set-env') {
set-env $parts[1] $parts[2]
} elif (==s $parts[0] 'unset-env') {
@ -31,16 +31,16 @@ fn asdf [command @args]{
}
}
fn match [argz @pats]{
fn match {|argz @pats|
var matched = $true;
if (!= (count $argz) (count $pats)) {
matched = $false
set matched = $false
} else {
for i [(range (count $pats))] {
pat = '^'$pats[$i]'$'
arg = $argz[$i]
var pat = '^'$pats[$i]'$'
var arg = $argz[$i]
if (not (re:match $pat $arg)) {
matched = $false
set matched = $false
break
}
}
@ -48,14 +48,14 @@ fn match [argz @pats]{
put $matched
}
fn ls-shims []{
fn ls-shims {
ls $asdf_data_dir'/shims'
}
fn ls-executables []{
fn ls-executables {
# Print all executable files and links in path
try {
find $@paths '(' -type f -o -type l ')' -print 2>/dev/null | each [p]{
find $@paths '(' -type f -o -type l ')' -print 2>/dev/null | each {|p|
try {
if (test -x $p) {
path:base $p
@ -69,14 +69,14 @@ fn ls-executables []{
}
}
fn ls-installed-versions [plugin_name]{
asdf list $plugin_name | each [version]{
fn ls-installed-versions {|plugin_name|
asdf list $plugin_name | each {|version|
put (re:replace '\s*(.*)\s*' '${1}' $version)
}
}
fn ls-all-versions [plugin_name]{
asdf list-all $plugin_name | each [version]{
fn ls-all-versions {|plugin_name|
asdf list-all $plugin_name | each {|version|
put (re:replace '\s*(.*)\s*' '${1}' $version)
}
}
@ -87,7 +87,7 @@ for path [
$asdf_data_dir'/shims'
] {
if (not (has-value $paths $path)) {
paths = [
set paths = [
$@paths
$path
]
@ -95,12 +95,12 @@ for path [
}
# Setup argument completions
fn arg-completer [@argz]{
argz = $argz[1:-1] # strip 'asdf' and trailing empty string
fn arg-completer {|@argz|
set argz = $argz[1..-1] # strip 'asdf' and trailing empty string
var num = (count $argz)
if (== $num 0) {
# list all subcommands
find $asdf_dir'/lib/commands' -name 'command-*' | each [cmd]{
find $asdf_dir'/lib/commands' -name 'command-*' | each {|cmd|
put (re:replace '.*/command-(.*)\.bash' '${1}' $cmd)
}
put 'plugin'
@ -176,7 +176,7 @@ fn arg-completer [@argz]{
put '--parent'
} elif (or (match $argz 'plugin-add') (match $argz 'plugin' 'add')) {
# asdf plugin add <name>
asdf plugin-list-all | each [line]{
asdf plugin-list-all | each {|line|
put (re:replace '([^\s]+)\s+.*' '${1}' $line)
}
} elif (or (match $argz 'plugin-list') (match $argz 'plugin' 'list')) {
@ -190,13 +190,13 @@ fn arg-completer [@argz]{
} elif (or (match $argz 'plugin-remove') (match $argz 'plugin' 'remove')) {
# asdf plugin remove <name>
asdf plugin-list
} elif (and (>= (count $argz) 3) (match $argz[:3] 'plugin-test' '.*' '.*')) {
} elif (and (>= (count $argz) 3) (match $argz[..3] 'plugin-test' '.*' '.*')) {
# asdf plugin-test <plugin-name> <plugin-url> [--asdf-tool-version <version>] [--asdf-plugin-gitref <git-ref>] [test-command*]
put '--asdf-plugin-gitref'
put '--asdf-tool-version'
ls-executables
ls-shims
} elif (and (>= (count $argz) 4) (match $argz[:4] 'plugin' 'test' '.*' '.*')) {
} elif (and (>= (count $argz) 4) (match $argz[..4] 'plugin' 'test' '.*' '.*')) {
# asdf plugin test <plugin-name> <plugin-url> [--asdf-tool-version <version>] [--asdf-plugin-gitref <git-ref>] [test-command*]
put '--asdf-plugin-gitref'
put '--asdf-tool-version'
@ -208,7 +208,7 @@ fn arg-completer [@argz]{
put '--all'
} elif (match $argz 'plugin') {
# list plugin-* subcommands
find $asdf_dir'/lib/commands' -name 'command-plugin-*' | each [cmd]{
find $asdf_dir'/lib/commands' -name 'command-plugin-*' | each {|cmd|
put (re:replace '.*/command-plugin-(.*)\.bash' '${1}' $cmd)
}
} elif (match $argz 'reshim') {

View File

@ -148,12 +148,12 @@ Completions are automatically configured on installation by the AUR package.
::: details Elvish & Git
Add `asdf.elv` to your `~/.elvish/rc.elv` with:
Add `asdf.elv` to your `~/.config/elvish/rc.elv` with:
```shell:no-line-numbers
mkdir -p ~/.elvish/lib; ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv
echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv
mkdir -p ~/.config/elvish/lib; ln -s ~/.asdf/asdf.elv ~/.config/elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv
echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv
```
Completions are automatically configured.
@ -162,12 +162,12 @@ Completions are automatically configured.
::: details Elvish & Homebrew
Add `asdf.elv` to your `~/.elvish/rc.elv` with:
Add `asdf.elv` to your `~/.config/elvish/rc.elv` with:
```shell:no-line-numbers
mkdir -p ~/.elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv
echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv
mkdir -p ~/.config/elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.config/elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv
echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv
```
Completions are automatically configured.
@ -175,12 +175,12 @@ Completions are automatically configured.
::: details Elvish & Pacman
Add `asdf.elv` to your `~/.elvish/rc.elv` with:
Add `asdf.elv` to your `~/.config/elvish/rc.elv` with:
```shell:no-line-numbers
mkdir -p ~/.elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv
echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv
mkdir -p ~/.config/elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.config/elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv
echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv
```
Completions are automatically configured.

View File

@ -259,17 +259,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc
::: details Elvish & Git
1. In your `~/.elvish/rc.elv` remove the lines that use the `asdf` module:
1. In your `~/.config/elvish/rc.elv` remove the lines that use the `asdf` module:
```shell
use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}
edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
use asdf _asdf; var asdf~ = $_asdf:asdf~
set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
```
and uninstall the `asdf` module with this command:
```shell:no-line-numbers
rm -f ~/.elvish/lib/asdf.elv
rm -f ~/.config/elvish/lib/asdf.elv
```
2. Remove the `$HOME/.asdf` dir:
@ -288,17 +288,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc
::: details Elvish & Homebrew
1. In your `~/.elvish/rc.elv` remove the lines that use the `asdf` module:
1. In your `~/.config/elvish/rc.elv` remove the lines that use the `asdf` module:
```shell
use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}
edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
use asdf _asdf; var asdf~ = $_asdf:asdf~
set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
```
and uninstall the `asdf` module with this command:
```shell:no-line-numbers
rm -f ~/.elvish/lib/asdf.elv
rm -f ~/.config/elvish/lib/asdf.elv
```
2. Uninstall with your package manager:
@ -317,17 +317,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc
::: details Elvish & Pacman
1. In your `~/.elvish/rc.elv` remove the lines that use the `asdf` module:
1. In your `~/.config/elvish/rc.elv` remove the lines that use the `asdf` module:
```shell
use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}
edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
use asdf _asdf; var asdf~ = $_asdf:asdf~
set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
```
and uninstall the `asdf` module with this command:
```shell:no-line-numbers
rm -f ~/.elvish/lib/asdf.elv
rm -f ~/.config/elvish/lib/asdf.elv
```
2. Uninstall with your package manager:

View File

@ -148,12 +148,12 @@ O auto completar é configurado automaticamente durante a instalação do pacote
::: details Elvish & Git
Add `asdf.elv` to your `~/.elvish/rc.elv` with:
Add `asdf.elv` to your `~/.config/elvish/rc.elv` with:
```shell:no-line-numbers
mkdir -p ~/.elvish/lib; ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv
echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv
mkdir -p ~/.config/elvish/lib; ln -s ~/.asdf/asdf.elv ~/.config/elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv
echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv
```
Completions are automatically configured.
@ -162,12 +162,12 @@ Completions are automatically configured.
::: details Elvish & Homebrew
Add `asdf.elv` to your `~/.elvish/rc.elv` with:
Add `asdf.elv` to your `~/.config/elvish/rc.elv` with:
```shell:no-line-numbers
mkdir -p ~/.elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv
echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv
mkdir -p ~/.config/elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.config/elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv
echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv
```
Completions are automatically configured.
@ -175,12 +175,12 @@ Completions are automatically configured.
::: details Elvish & Pacman
Add `asdf.elv` to your `~/.elvish/rc.elv` with:
Add `asdf.elv` to your `~/.config/elvish/rc.elv` with:
```shell:no-line-numbers
mkdir -p ~/.elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv
echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv
mkdir -p ~/.config/elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.config/elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv
echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv
```
Completions are automatically configured.

View File

@ -261,17 +261,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc
::: details Elvish & Git
1. Em seu `~/.elvish/rc.elv` remova as linhas que importa o módulo `asdf`:
1. Em seu `~/.config/elvish/rc.elv` remova as linhas que importa o módulo `asdf`:
```shell
use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}
edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
use asdf _asdf; var asdf~ = $_asdf:asdf~
set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
```
e desinstale o módulo `asdf` com este comando:
```shell:no-line-numbers
rm -f ~/.elvish/lib/asdf.elv
rm -f ~/.config/elvish/lib/asdf.elv
```
2. Remova o diretório `$HOME/.asdf`:
@ -290,17 +290,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc
::: details Elvish & Homebrew
1. Em seu `~/.elvish/rc.elv` remova as linhas que importa o módulo `asdf`:
1. Em seu `~/.config/elvish/rc.elv` remova as linhas que importa o módulo `asdf`:
```shell
use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}
edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
use asdf _asdf; var asdf~ = $_asdf:asdf~
set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
```
e desinstale o módulo `asdf` com este comando:
```shell:no-line-numbers
rm -f ~/.elvish/lib/asdf.elv
rm -f ~/.config/elvish/lib/asdf.elv
```
2. Desinstale com seu gerenciador de pacotes:
@ -319,17 +319,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc
::: details Elvish & Pacman
1. Em seu `~/.elvish/rc.elv` remova as linhas que importa o módulo `asdf`:
1. Em seu `~/.config/elvish/rc.elv` remova as linhas que importa o módulo `asdf`:
```shell
use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}
edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
use asdf _asdf; var asdf~ = $_asdf:asdf~
set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
```
e desinstale o módulo `asdf` com este comando:
```shell:no-line-numbers
rm -f ~/.elvish/lib/asdf.elv
rm -f ~/.config/elvish/lib/asdf.elv
```
2. Desinstale com seu gerenciador de pacotes:

View File

@ -148,12 +148,12 @@ source /opt/asdf-vm/asdf.fish
::: details Elvish & Git
使用以下命令将 `asdf.elv` 加入到 `~/.elvish/rc.elv` 文件中:
使用以下命令将 `asdf.elv` 加入到 `~/.config/elvish/rc.elv` 文件中:
```shell:no-line-numbers
mkdir -p ~/.elvish/lib; ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv
echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv
mkdir -p ~/.config/elvish/lib; ln -s ~/.asdf/asdf.elv ~/.config/elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv
echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv
```
补全功能将会自动配置。
@ -162,12 +162,12 @@ echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elv
::: details Elvish & Homebrew
使用以下命令将 `asdf.elv` 加入到 `~/.elvish/rc.elv` 文件中:
使用以下命令将 `asdf.elv` 加入到 `~/.config/elvish/rc.elv` 文件中:
```shell:no-line-numbers
mkdir -p ~/.elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv
echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv
mkdir -p ~/.config/elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.config/elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv
echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv
```
补全功能将会自动配置。
@ -176,12 +176,12 @@ echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elv
::: details Elvish & Pacman
使用以下命令将 `asdf.elv` 加入到 `~/.elvish/rc.elv` 文件中:
使用以下命令将 `asdf.elv` 加入到 `~/.config/elvish/rc.elv` 文件中:
```shell:no-line-numbers
mkdir -p ~/.elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv
echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv
mkdir -p ~/.config/elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.config/elvish/lib/asdf.elv
echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv
echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv
```
补全功能将会自动配置。

View File

@ -259,17 +259,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc
::: details Elvish & Git
1. 在 `~/.elvish/rc.elv` 配置文件中移除使用 `asdf` 模块的行:
1. 在 `~/.config/elvish/rc.elv` 配置文件中移除使用 `asdf` 模块的行:
```shell
use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}
use asdf _asdf; var asdf~ = $_asdf:asdf~
edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
```
以及使用以下命令卸载 `asdf` 模块:
```shell:no-line-numbers
rm -f ~/.elvish/lib/asdf.elv
rm -f ~/.config/elvish/lib/asdf.elv
```
2. 移除 `$HOME/.asdf` 目录:
@ -288,17 +288,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc
::: details Elvish & Homebrew
1. 在 `~/.elvish/rc.elv` 配置文件中移除使用 `asdf` 模块的行:
1. 在 `~/.config/elvish/rc.elv` 配置文件中移除使用 `asdf` 模块的行:
```shell
use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}
use asdf _asdf; var asdf~ = $_asdf:asdf~
edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
```
以及使用以下命令卸载 `asdf` 模块:
```shell:no-line-numbers
rm -f ~/.elvish/lib/asdf.elv
rm -f ~/.config/elvish/lib/asdf.elv
```
2. 用包管理器卸载:
@ -317,17 +317,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc
::: details Elvish & Pacman
1. 在 `~/.elvish/rc.elv` 配置文件中移除使用 `asdf` 模块的行:
1. 在 `~/.config/elvish/rc.elv` 配置文件中移除使用 `asdf` 模块的行:
```shell
use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}
use asdf _asdf; var asdf~ = $_asdf:asdf~
edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
```
以及使用以下命令卸载 `asdf` 模块:
```shell:no-line-numbers
rm -f ~/.elvish/lib/asdf.elv
rm -f ~/.config/elvish/lib/asdf.elv
```
2. 用包管理器卸载:

View File

@ -4,12 +4,12 @@ load test_helpers
setup() {
cd $(dirname "$BATS_TEST_DIRNAME")
mkdir -p $HOME/.elvish/lib
cp ./asdf.elv $HOME/.elvish/lib/asdftest.elv
mkdir -p $HOME/.config/elvish/lib
cp ./asdf.elv $HOME/.config/elvish/lib/asdftest.elv
}
teardown() {
rm $HOME/.elvish/lib/asdftest.elv
rm $HOME/.config/elvish/lib/asdftest.elv
}
cleaned_path() {
@ -19,8 +19,8 @@ cleaned_path() {
@test "exports ASDF_DIR" {
output=$(elvish -norc -c "
unset-env ASDF_DIR
paths = [$(cleaned_path)]
use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args}
set paths = [$(cleaned_path)]
use asdftest _asdf; var asdf~ = \$_asdf:asdf~
echo \$E:ASDF_DIR
")
[ "$?" -eq 0 ]
@ -30,8 +30,8 @@ cleaned_path() {
@test "retains ASDF_DIR" {
output=$(elvish -norc -c "
set-env ASDF_DIR "/path/to/asdf"
paths = [$(cleaned_path)]
use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args}
set paths = [$(cleaned_path)]
use asdftest _asdf; var asdf~ = \$_asdf:asdf~
echo \$E:ASDF_DIR
")
[ "$?" -eq 0 ]
@ -41,8 +41,8 @@ cleaned_path() {
@test "retains ASDF_DATA_DIR" {
output=$(elvish -norc -c "
set-env ASDF_DATA_DIR "/path/to/asdf-data"
paths = [$(cleaned_path)]
use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args}
set paths = [$(cleaned_path)]
use asdftest _asdf; var asdf~ = \$_asdf:asdf~
echo \$E:ASDF_DATA_DIR
")
[ "$?" -eq 0 ]
@ -52,8 +52,8 @@ cleaned_path() {
@test "adds asdf dirs to PATH" {
result=$(elvish -norc -c "
unset-env ASDF_DIR
paths = [$(cleaned_path)]
use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args}
set paths = [$(cleaned_path)]
use asdftest _asdf; var asdf~ = \$_asdf:asdf~
echo \$E:PATH
")
[ "$?" -eq 0 ]
@ -65,8 +65,8 @@ cleaned_path() {
@test "defines the _asdf namespace" {
output=$(elvish -norc -c "
unset-env ASDF_DIR
paths = [$(cleaned_path)]
use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args}
set paths = [$(cleaned_path)]
use asdftest _asdf; var asdf~ = \$_asdf:asdf~
pprint \$_asdf:
")
[ "$?" -eq 0 ]
@ -76,8 +76,8 @@ cleaned_path() {
@test "defines the asdf function" {
output=$(elvish -norc -c "
unset-env ASDF_DIR
paths = [$(cleaned_path)]
use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args}
set paths = [$(cleaned_path)]
use asdftest _asdf; var asdf~ = \$_asdf:asdf~
pprint \$asdf~
")
[ "$?" -eq 0 ]
@ -88,8 +88,8 @@ cleaned_path() {
@test "function calls asdf command" {
result=$(elvish -norc -c "
set-env ASDF_DIR $(pwd)
paths = [$(cleaned_path)]
use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args}
set paths = [$(cleaned_path)]
use asdftest _asdf; var asdf~ = \$_asdf:asdf~
asdf info
")
[ "$?" -eq 0 ]