summaryrefslogtreecommitdiff
path: root/pkgtools/pkg_regress
diff options
context:
space:
mode:
authorgavan <gavan@pkgsrc.org>2004-08-28 00:26:57 +0000
committergavan <gavan@pkgsrc.org>2004-08-28 00:26:57 +0000
commit53e772c848ec42984469b6ddbfd22c1e15730fc4 (patch)
treee4235799a10263b776d2c7e69ac584f590c6a0f1 /pkgtools/pkg_regress
parent3a14c3f858796273b66586550af416932f3d8dfc (diff)
downloadpkgsrc-53e772c848ec42984469b6ddbfd22c1e15730fc4.tar.gz
Add pkg_regress, a regression testing system for the pkgsrc infrastructure.
Tests are found in pkgsrc/regress, tests are run by executing pkg_regress. Based on an idea discussed at pkgsrcCon 2004. Thanks to dillo@ for review and refinements, and to jlam@ for review.
Diffstat (limited to 'pkgtools/pkg_regress')
-rw-r--r--pkgtools/pkg_regress/DESCR1
-rw-r--r--pkgtools/pkg_regress/Makefile33
-rw-r--r--pkgtools/pkg_regress/PLIST2
-rwxr-xr-xpkgtools/pkg_regress/files/pkg_regress.sh145
4 files changed, 181 insertions, 0 deletions
diff --git a/pkgtools/pkg_regress/DESCR b/pkgtools/pkg_regress/DESCR
new file mode 100644
index 00000000000..31422d1372c
--- /dev/null
+++ b/pkgtools/pkg_regress/DESCR
@@ -0,0 +1 @@
+pkg_regress runs the regression test suite for the pkgsrc infrastructure.
diff --git a/pkgtools/pkg_regress/Makefile b/pkgtools/pkg_regress/Makefile
new file mode 100644
index 00000000000..03174c55a95
--- /dev/null
+++ b/pkgtools/pkg_regress/Makefile
@@ -0,0 +1,33 @@
+# $NetBSD: Makefile,v 1.1 2004/08/28 00:26:57 gavan Exp $
+
+DISTNAME= pkg_regress-0.0
+CATEGORIES= pkgtools
+MASTER_SITES= # empty
+DISTFILES= # empty
+
+MAINTAINER= gavan@NetBSD.org
+HOMEPAGE= ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/Packages.txt
+COMMENT= Run pkgsrc infrastructure regression test suite
+
+PKG_INSTALLATION_TYPES= overwrite pkgviews
+
+WRKSRC= ${WRKDIR}
+EXTRACT_ONLY= # empty
+USE_LANGUAGES= # empty
+NO_CHECKSUM= YES
+
+INSTALLATION_DIRS= sbin
+
+.include "../../mk/bsd.prefs.mk"
+
+do-build:
+ ${SED} -e 's#@MAKE@#${MAKE}#g' \
+ -e 's#@PKGSRCDIR@#${_PKGSRCDIR}#g' \
+ -e 's#@SH@#${SH}#g' \
+ -e 's#@EGREP@#${EGREP}#g' \
+ ${FILESDIR}/pkg_regress.sh >${WRKSRC}/pkg_regress.sh
+
+do-install:
+ ${INSTALL_SCRIPT} ${WRKSRC}/pkg_regress.sh ${PREFIX}/sbin/pkg_regress
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/pkgtools/pkg_regress/PLIST b/pkgtools/pkg_regress/PLIST
new file mode 100644
index 00000000000..83382cef77e
--- /dev/null
+++ b/pkgtools/pkg_regress/PLIST
@@ -0,0 +1,2 @@
+@comment $NetBSD: PLIST,v 1.1 2004/08/28 00:26:57 gavan Exp $
+sbin/pkg_regress
diff --git a/pkgtools/pkg_regress/files/pkg_regress.sh b/pkgtools/pkg_regress/files/pkg_regress.sh
new file mode 100755
index 00000000000..361f3f57e68
--- /dev/null
+++ b/pkgtools/pkg_regress/files/pkg_regress.sh
@@ -0,0 +1,145 @@
+#!@SH@ -e
+#
+# $NetBSD: pkg_regress.sh,v 1.1 2004/08/28 00:28:36 gavan Exp $
+#
+
+if [ -z "$PKGSRCDIR" ]
+then
+ PKGSRCDIR=@PKGSRCDIR@
+fi
+
+TEST_EGREP=@EGREP@
+TEST_MAKE=@MAKE@
+
+# hooks overridable by test spec file
+
+do_setup()
+{
+}
+
+do_cleanup()
+{
+}
+
+check_result()
+{
+}
+
+# result checking routines
+
+exit_status()
+{
+ # Test exit status
+ if [ "$1" -ne "${TEST_EXITSTATUS}" ]
+ then
+ TEST_RESULT=1
+ fi
+}
+
+output_require()
+{
+ # Test positive match against output
+ for PATTERN in "$@"
+ do
+ if ! ${TEST_EGREP} -q "${PATTERN}" <${TEST_OUTFILE} >/dev/null
+ then
+ TEST_RESULT=1
+ fi
+ done
+}
+
+output_prohibit()
+{
+ # Test negative match against output
+ for PATTERN in "$@"
+ do
+ if ${TEST_EGREP} -q "${PATTERN}" <${TEST_OUTFILE} >/dev/null
+ then
+ TEST_RESULT=1
+ fi
+ done
+}
+
+# runtest runs a test in a subshell, so that environment settings etc in
+# one test do not interfere with other tests.
+runtest() {
+ if (
+ cd $1
+ TEST_RESULT=0
+ TEST_EXITSTATUS=0
+ TEST_OUTFILE=`mktemp -t pkg_regress` || exit 1
+ . ./spec
+
+ do_setup
+
+ # Run the test. We use an if statement to ensure that the script
+ # isn't terminated if it is executed with sh -e.
+ if ${TEST_MAKE} ${MAKEARGS_TEST} >${TEST_OUTFILE} 2>&1
+ then
+ TEST_EXITSTATUS=$?
+ else
+ TEST_EXITSTATUS=$?
+ fi
+
+ check_result
+
+ # Perform cleanup
+
+ do_cleanup
+
+ if [ -n "${MAKEARGS_CLEAN}" ]
+ then
+ ${TEST_MAKE} ${MAKEARGS_CLEAN} >>${TEST_OUTFILE}
+ fi
+
+ if [ -n "${TEST_VERBOSE}" ]
+ then
+ cat ${TEST_OUTFILE}
+ fi
+
+ rm -f ${TEST_OUTFILE}
+ exit ${TEST_RESULT}
+ )
+ then
+ TEST_PASS=`expr ${TEST_PASS} + 1`
+ else
+ TEST_FAIL=`expr ${TEST_FAIL} + 1`
+ TEST_FAILURES="${TEST_FAILURES} $1"
+ fi
+}
+
+
+TEST_PASS=0
+TEST_FAIL=0
+TEST_FAILURES=
+
+cd $PKGSRCDIR/regress
+
+case $1 in
+ -v) TEST_VERBOSE=1
+ shift ;;
+esac
+
+if [ $# -ne 0 ]
+then
+ TEST_LIST="$@"
+else
+ TEST_LIST="*"
+fi
+
+for dir in ${TEST_LIST}
+do
+ if [ -f $dir/spec ]
+ then
+ runtest $dir
+ fi
+done
+
+if [ -n "${TEST_FAILURES}" ]
+then
+ echo "Tests failed: ${TEST_FAILURES}"
+ echo
+fi
+
+echo "Statistics:"
+echo " $TEST_PASS passed, $TEST_FAIL failed"