7
export XDG_CONFIG_HOME=
11
if ! command -v elvish &>/dev/null && [ -z "$GITHUB_ACTIONS" ]; then
12
skip 'Elvish not installed'
18
IFS='.' read -r ver_major ver_minor ver_patch <<<"$(elvish -version)"
20
if ((ver_major == 0 && ver_minor < 18)) && [ -z "$GITHUB_ACTIONS" ]; then
21
skip "Elvish version is not at least 0.18. Found ${ver_major}.${ver_minor}.${ver_patch}"
26
echo "$PATH" | tr ':' '\n' | grep -v "asdf" | tr '\n' ' '
29
@test "exports ASDF_DIR" {
32
set paths = [$(cleaned_path)]
33
use ./asdf _asdf; var asdf~ = \$_asdf:asdf~
37
[ "$output" = "$HOME/.asdf" ]
40
@test "retains ASDF_DIR" {
42
set-env ASDF_DIR \"/path/to/asdf\"
43
set paths = [$(cleaned_path)]
44
use ./asdf _asdf; var asdf~ = \$_asdf:asdf~
48
[ "$output" = "/path/to/asdf" ]
51
@test "retains ASDF_DATA_DIR" {
53
set-env ASDF_DATA_DIR \"/path/to/asdf-data\"
54
set paths = [$(cleaned_path)]
55
use ./asdf _asdf; var asdf~ = \$_asdf:asdf~
56
echo \$E:ASDF_DATA_DIR"
59
[ "$output" = "/path/to/asdf-data" ]
62
@test "adds asdf dirs to PATH" {
65
set paths = [$(cleaned_path)]
66
use ./asdf _asdf; var asdf~ = \$_asdf:asdf~
71
result=$(echo "$output" | grep "asdf")
75
@test "defines the _asdf namespace" {
78
set paths = [$(cleaned_path)]
79
use ./asdf _asdf; var asdf~ = \$_asdf:asdf~
83
[[ "$output" =~ "<ns " ]]
86
@test "does not add paths to PATH more than once" {
89
set paths = [$(cleaned_path)]
91
use ./asdf _asdf; var asdf~ = \$_asdf:asdf~
92
use ./asdf _asdf; var asdf~ = \$_asdf:asdf~
97
result=$(echo "$result" | tr ':' '\n' | grep "asdf" | sort | uniq -d)
101
@test "defines the asdf function" {
102
run elvish -norc -c "
104
set paths = [$(cleaned_path)]
105
use ./asdf _asdf; var asdf~ = \$_asdf:asdf~
109
[[ "$output" =~ "<closure " ]]
112
@test "function calls asdf command" {
113
run elvish -norc -c "
114
set-env ASDF_DIR $(pwd) # checkstyle-ignore
115
set paths = [$(cleaned_path)]
116
use ./asdf _asdf; var asdf~ = \$_asdf:asdf~
121
result=$(echo "$output" | grep "ASDF INSTALLED PLUGINS:")