1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-21 10:37:58 +03:00
mal/run_argv_test.sh
Dov Murik d3c401c1e8 tests: Test *ARGV* is set correctly in step 6
Add new mini test harness run_argv_test.sh to run the Mal interpreter
with different command-line arguments and test the stdout of that
process.

The main Makefile will automatically run the new harness whenever step 6
is tested (either directly or during REGRESS=1 of a more advanced step).
2016-05-11 11:31:04 -04:00

37 lines
692 B
Bash
Executable File

#!/bin/bash
#
# Usage: run_argv_test.sh <command line arguments to run mal>
#
# Example: run_argv_test.sh python step6_file.py
#
assert_equal() {
if [ "$1" = "$2" ] ; then
echo "OK: '$1'"
else
echo "FAIL: Expected '$1' but got '$2'"
echo
exit 1
fi
}
if [ -z "$1" ] ; then
echo "Usage: $0 <command line arguments to run mal>"
exit 1
fi
root="$(dirname $0)"
out="$( $@ $root/tests/print_argv.mal aaa bbb ccc )"
assert_equal '("aaa" "bbb" "ccc")' "$out"
out="$( $@ $root/tests/print_argv.mal aaa 'bbb ccc' ddd )"
assert_equal '("aaa" "bbb ccc" "ddd")' "$out"
out="$( $@ $root/tests/print_argv.mal )"
assert_equal '()' "$out"
echo 'Passed all *ARGV* tests'
echo