Skip to content

Commit

Permalink
maint: Add basic tests for cp/mv/atclone/make ices
Browse files Browse the repository at this point in the history
zunit runs tests non-interactively and these tests fail without the fix in this branch.
  • Loading branch information
jankatins committed Jul 29, 2022
1 parent 47156d8 commit a115aa3
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ jobs:
- name: "gh-r"
run: zunit run tests/gh-r.zunit

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

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

Expand Down
52 changes: 52 additions & 0 deletions tests/ices.zunit
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env zunit

@setup {
ZPLUGINS=$ZINIT[PLUGINS_DIR]

function _zunit_assert_not_exists() {
local pathname=$1 filepath

# If filepath is relative, prepend the test directory
if [[ "${pathname:0:1}" != "/" ]]; then
filepath="$testdir/${pathname}"
else
filepath="$pathname"
fi

[[ ! -e "$filepath" ]] && return 0

echo "'$pathname' does exist"
exit 1
}

}

@test 'mv' {
run zinit as"null" id-as"test/mv" mv"readme.md -> mv.md" for zdharma-continuum/null
assert $state equals 0
assert "$ZPLUGINS/test---mv/mv.md" is_file
assert "$ZPLUGINS/test---mv/mv.md" is_file
assert "$ZPLUGINS/test---mv/readme.md" not_exists
}

@test 'cp' {
run zinit as"null" id-as"test/cp" cp"readme.md -> cp.md" for zdharma-continuum/null
assert $state equals 0
assert "$ZPLUGINS/test---cp/cp.md" is_file
assert "$ZPLUGINS/test---cp/cp.md" is_readable
assert "$ZPLUGINS/test---cp/readme.md" is_file
}

@test 'atclone' {
run zinit as"null" id-as"test/atclone" atclone"mv readme.md atclone.md" for zdharma-continuum/null
assert $state equals 0
assert "$ZPLUGINS/test---atclone/atclone.md" is_file
assert "$ZPLUGINS/test---atclone/atclone.md" is_readable
assert "$ZPLUGINS/test---atclone/readme.md" not_exists
}

@test 'make' {
run zinit as"null" id-as"test/make" atclone"printf 'all:\n\ttouch whatever\n' > Makefile" make"" for zdharma-continuum/null
assert $state equals 0
assert "$ZPLUGINS/test---make/whatever" is_file
}

0 comments on commit a115aa3

Please sign in to comment.