Skip to content

Commit

Permalink
Add tests to test shell features
Browse files Browse the repository at this point in the history
The idea with these tests is to test every shell feature that
Liquidprompt uses and test that it works in the way that we expect. Not
only can this help debug more complicated tests, but it can act as a
quick exam for a new shell candidate to pass before being supported.

Right now only Bash and Zsh are supported, but these tests were written
with Ksh in mind. I doubt that Ksh would ever be supported, but it could
be possible.
  • Loading branch information
Rycieos committed Oct 30, 2020
1 parent ec891ea commit 46918f6
Show file tree
Hide file tree
Showing 3 changed files with 466 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

shells=(bash zsh)

cd "${0%/*}/tests"

if [ ! -r shunit2 ]; then
curl https://raw.githubusercontent.com/kward/shunit2/v2.1.8/shunit2 -O
fi

typeset -a testing_shells

for shell in "${shells[@]}"; do
if command -v "$shell" >/dev/null; then
testing_shells+=("$shell")
else
printf "Cannot find shell '%s', skipping tests\n" "$shell" >&2
fi
done

for test_file in ./test_*.sh; do
for shell in "${testing_shells[@]}"; do
printf "Running shell '%s' with test '%s'\n" "$shell" "$test_file"
$shell "$test_file" || exit $?
done
done
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shunit2

0 comments on commit 46918f6

Please sign in to comment.