diff options
author | rillig <rillig> | 2005-11-24 19:18:45 +0000 |
---|---|---|
committer | rillig <rillig> | 2005-11-24 19:18:45 +0000 |
commit | ac0a03e060ffdafafa59c05b2ea9611848787e9d (patch) | |
tree | 3fda8828af3027568201289b0562f459e05a1592 /regress/tools | |
parent | 83b9f05cf77b4285936d9d4bd19319feabdb89fb (diff) | |
download | pkgsrc-ac0a03e060ffdafafa59c05b2ea9611848787e9d.tar.gz |
Factored out the generally useable shell functions into tests.subr, as they
will be used by almost all test cases.
Diffstat (limited to 'regress/tools')
-rw-r--r-- | regress/tools/files/awk-test.sh | 34 | ||||
-rw-r--r-- | regress/tools/files/tests.subr | 33 |
2 files changed, 36 insertions, 31 deletions
diff --git a/regress/tools/files/awk-test.sh b/regress/tools/files/awk-test.sh index 828904ec209..2b28eb03cd1 100644 --- a/regress/tools/files/awk-test.sh +++ b/regress/tools/files/awk-test.sh @@ -1,39 +1,11 @@ #! /bin/sh -# $NetBSD: awk-test.sh,v 1.5 2005/11/19 22:55:24 rillig Exp $ +# $NetBSD: awk-test.sh,v 1.6 2005/11/24 19:18:45 rillig Exp $ # set -e -# usage: testcase_start <testname> -testcase_start() { - printf "Running testcase %s\\n" "$1" -} - -# usage: assert_equal <testname> <expected> <got> -assert_equal() { - case $2 in - "$3") ;; - *) echo "[assert_equal:$1] expected \"$2\", got \"$3\"." 1>&2 - return 1;; - esac -} - -# usage: test_assignment <testname> <input> <expected-output> -test_assignment() { - testcase_start "$1" - o=`echo "" | awk '{print var}' var="$2"` - assert_equal "$1" "$3" "${o}" -} - -# usage: test_passline <testname> <input> -test_passline() { - testcase_start "$1" - o=`awk '{print}' <<EOF -$2 -EOF -` - assert_equal "$1" "$2" "${o}" -} +mydir=`dirname "$0"` +. "${mydir}/tests.subr" # # Assignment of variables from the command line. The Solaris diff --git a/regress/tools/files/tests.subr b/regress/tools/files/tests.subr new file mode 100644 index 00000000000..204657b364a --- /dev/null +++ b/regress/tools/files/tests.subr @@ -0,0 +1,33 @@ +# $NetBSD: tests.subr,v 1.1 2005/11/24 19:18:45 rillig Exp $ +# + +# usage: testcase_start <testname> +testcase_start() { + printf " Running testcase %s\\n" "$1" +} + +# usage: assert_equal <testname> <expected> <got> +assert_equal() { + case $2 in + "$3") ;; + *) echo "[assert_equal:$1] expected \"$2\", got \"$3\"." 1>&2 + return 1;; + esac +} + +# usage: test_assignment <testname> <input> <expected-output> +test_assignment() { + testcase_start "$1" + o=`echo "" | awk '{print var}' var="$2"` + assert_equal "$1" "$3" "${o}" +} + +# usage: test_passline <testname> <input> +test_passline() { + testcase_start "$1" + o=`awk '{print}' <<EOF +$2 +EOF +` + assert_equal "$1" "$2" "${o}" +} |