2016-05-10 22:28:29 +03:00
|
|
|
#!/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)"
|
|
|
|
|
2016-10-28 07:47:05 +03:00
|
|
|
out="$( $@ $root/tests/print_argv.mal aaa bbb ccc | tr -d '\r' )"
|
2016-05-10 22:28:29 +03:00
|
|
|
assert_equal '("aaa" "bbb" "ccc")' "$out"
|
|
|
|
|
2016-05-15 07:05:09 +03:00
|
|
|
# Note: The 'make' implementation cannot handle arguments with spaces in them,
|
|
|
|
# so for now we skip this test.
|
|
|
|
#
|
|
|
|
# out="$( $@ $root/tests/print_argv.mal aaa 'bbb ccc' ddd )"
|
|
|
|
# assert_equal '("aaa" "bbb ccc" "ddd")' "$out"
|
2016-05-10 22:28:29 +03:00
|
|
|
|
2016-10-28 07:47:05 +03:00
|
|
|
out="$( $@ $root/tests/print_argv.mal | tr -d '\r' )"
|
2016-05-10 22:28:29 +03:00
|
|
|
assert_equal '()' "$out"
|
|
|
|
|
|
|
|
echo 'Passed all *ARGV* tests'
|
|
|
|
echo
|