pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/regress/tools/files Factored out the generally useable...
details: https://anonhg.NetBSD.org/pkgsrc/rev/a8106ee8646d
branches: trunk
changeset: 503664:a8106ee8646d
user: rillig <rillig%pkgsrc.org@localhost>
date: Thu Nov 24 19:18:45 2005 +0000
description:
Factored out the generally useable shell functions into tests.subr, as they
will be used by almost all test cases.
diffstat:
regress/tools/files/awk-test.sh | 34 +++-------------------------------
regress/tools/files/tests.subr | 33 +++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 31 deletions(-)
diffs (83 lines):
diff -r e7d723e94fc2 -r a8106ee8646d regress/tools/files/awk-test.sh
--- a/regress/tools/files/awk-test.sh Thu Nov 24 19:07:43 2005 +0000
+++ b/regress/tools/files/awk-test.sh Thu Nov 24 19:18:45 2005 +0000
@@ -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 -r e7d723e94fc2 -r a8106ee8646d regress/tools/files/tests.subr
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/tools/files/tests.subr Thu Nov 24 19:18:45 2005 +0000
@@ -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}"
+}
Home |
Main Index |
Thread Index |
Old Index