Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions assert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ assert() {
(( tests_ran++ )) || :
[[ -z "$DISCOVERONLY" ]] || return
expected=$(echo -ne "${2:-}")
result="$(eval 2>/dev/null $1 <<< ${3:-})" || true
result="$(eval 2>/dev/null "$1" <<< ${3:-})" || true
if [[ "$result" == "$expected" ]]; then
[[ -z "$DEBUG" ]] || echo -n .
return
Expand All @@ -119,7 +119,7 @@ assert_raises() {
(( tests_ran++ )) || :
[[ -z "$DISCOVERONLY" ]] || return
status=0
(eval $1 <<< ${3:-}) > /dev/null 2>&1 || status=$?
(eval "$1" <<< ${3:-}) > /dev/null 2>&1 || status=$?
expected=${2:-0}
if [[ "$status" -eq "$expected" ]]; then
[[ -z "$DEBUG" ]] || echo -n .
Expand Down
10 changes: 10 additions & 0 deletions tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ assert "seq 2" "1\n2" # multi-line output expected
assert_raises 'read a; exit $a' 42 "42" # variables still work
assert "echo 1;
echo 2 # ^" "1\n2" # semicolon required!

# support for multiline command
MULTILINE=$(cat <<EOF
# comment
echo -n "hello "
echo -n "world"
EOF
)
assert "$MULTILINE" "hello world" # output expected

assert_end demo

_clean() {
Expand Down