ports/84448: Add "make test" to ports
skv at FreeBSD.org
skv at FreeBSD.org
Mon Aug 1 17:20:28 UTC 2005
>Number: 84448
>Category: ports
>Synopsis: Add "make test" to ports
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Mon Aug 01 17:20:12 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: Sergey Skvortsov
>Release: FreeBSD 4.11-STABLE i386
>Organization:
<Organization of PR author (multiple lines)>
>Environment:
<Relevant environment information (multiple lines)>
>Description:
Add to ports ability to run tests.
To enable "test" target just define HAS_TEST variable in Makefile.
All perl ports have automatically activated tests.
New variables are introduced: TEST_DEPENDS, TEST_TARGET, TEST_WRKSRC, TEST_ENV, TEST_ARGS.
>How-To-Repeat:
<Code/input/activities to reproduce the problem (multiple lines)>
>Fix:
Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.515
diff -u -r1.515 bsd.port.mk
--- bsd.port.mk 24 Jun 2005 09:18:54 -0000 1.515
+++ bsd.port.mk 1 Aug 2005 17:11:22 -0000
@@ -477,6 +477,12 @@
# package depends on. "lib" is the name of a shared library.
# make will use "ldconfig -r" to search for the library.
# lib can contain extended regular expressions.
+# TEST_DEPENDS - A list of "path:dir[:target]" tuples of other ports this
+# package depends to test. The test done to determine
+# the existence of the dependency is the same as
+# FETCH_DEPENDS. This will be checked during the
+# "test" stage. If the third field ("target") exists,
+# it will be used instead of ${DEPENDS_TARGET}.
# DEPENDS - A list of "dir[:target]" tuples of other ports this
# package depends on being made first. Use this only for
# things that don't fall into the above four categories.
@@ -628,6 +634,9 @@
# build-depends-list
# - Show all directories which are build-dependencies
# for this port.
+# test-depends-list
+# - Show all directories which are test-dependencies
+# for this port.
# package-depends-list
# - Show all directories which are
# package-dependencies for this port.
@@ -808,6 +817,19 @@
# MAKE_ARGS - Any extra arguments to sub-make in build and install stages.
# Default: none
#
+# For test:
+#
+# HAS_TEST - If set, this port has its own test suite. The
+# test stage will not do anything if this is not set.
+# TEST_TARGET
+# - Default target for sub-make in test stage.
+# Default: test
+# TEST_WRKSRC - Directory to do test in (default: ${WRKSRC}).
+# TEST_ENV - Additional environment vars passed to sub-make in test stage.
+# Default: see below
+# TEST_ARGS - Any extra arguments to sub-make in test stage.
+# Default: none
+#
# For install:
#
# INSTALL_TARGET
@@ -1399,6 +1421,7 @@
PATCH_WRKSRC?= ${WRKSRC}
CONFIGURE_WRKSRC?= ${WRKSRC}
BUILD_WRKSRC?= ${WRKSRC}
+TEST_WRKSRC?= ${WRKSRC}
INSTALL_WRKSRC?=${WRKSRC}
PLIST_SUB+= OSREL=${OSREL} PREFIX=%D LOCALBASE=${LOCALBASE} X11BASE=${X11BASE}
@@ -1425,6 +1448,7 @@
CONFIGURE_ENV+= SHELL=${SH} CONFIG_SHELL=${SH} PORTOBJFORMAT=${PORTOBJFORMAT}
SCRIPTS_ENV+= PORTOBJFORMAT=${PORTOBJFORMAT}
MAKE_ENV+= SHELL=${SH} PORTOBJFORMAT=${PORTOBJFORMAT}
+TEST_ENV+= SHELL=${SH}
PLIST_SUB+= PORTOBJFORMAT=${PORTOBJFORMAT}
.if defined(MANCOMPRESSED)
@@ -1692,6 +1716,7 @@
.if defined(PERL_MODBUILD)
PERL_CONFIGURE= yes
CONFIGURE_SCRIPT?= Build.PL
+HAS_TEST?= yes
.if ${PORTNAME} != Module-Build
BUILD_DEPENDS+= ${SITE_PERL}/Module/Build.pm:${PORTSDIR}/devel/p5-Module-Build
.endif
@@ -1707,6 +1732,7 @@
install_path=bindoc="${MAN1PREFIX}/man/man1"
.elif defined(PERL_CONFIGURE)
CONFIGURE_ARGS+= INSTALLDIRS="site"
+HAS_TEST?= yes
.endif
.if defined(PERL_CONFIGURE)
@@ -2156,6 +2182,7 @@
MOTIFLIB?= -L${X11BASE}/lib -lXm -lXp
ALL_TARGET?= all
+TEST_TARGET?= test
INSTALL_TARGET?= install
# This is a mid-term solution patch while pkg-comment files are
@@ -3378,6 +3405,35 @@
.endif
.endif
+# Test
+
+.if !target(do-test)
+do-test:
+.if defined(HAS_TEST)
+.if defined(USE_GMAKE)
+ @(cd ${BUILD_WRKSRC}; ${SETENV} ${TEST_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${TEST_ARGS} ${TEST_TARGET})
+.else
+.if defined(PERL_MODBUILD)
+ @(cd ${BUILD_WRKSRC}; ${SETENV} ${TEST_ENV} ${PERL5} ${PL_BUILD} ${TEST_ARGS} ${TEST_TARGET})
+.else
+ @(cd ${BUILD_WRKSRC}; ${SETENV} ${TEST_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${TEST_ARGS} ${TEST_TARGET})
+.endif
+.endif
+.endif
+.endif
+
+.if !target(test)
+test: build test-depends
+ @${ECHO_MSG} "===> Testing for ${PKGNAME}"
+.if target(pre-test)
+ @cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} pre-test
+.endif
+ @cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} do-test
+.if target(post-test)
+ @cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} post-test
+.endif
+.endif
+
# Check conflicts
.if !target(check-conflicts)
@@ -4289,7 +4345,7 @@
_DEPEND_ALWAYS= 0
.endif
-.for deptype in EXTRACT PATCH FETCH BUILD RUN
+.for deptype in EXTRACT PATCH FETCH BUILD RUN TEST
${deptype:L}-depends:
.if defined(${deptype}_DEPENDS)
.if !defined(NO_DEPENDS)
@@ -4464,13 +4520,13 @@
# Dependency lists: both build and runtime, recursive. Print out directory names.
all-depends-list:
-.if defined(EXTRACT_DEPENDS) || defined(PATCH_DEPENDS) || defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || defined(LIB_DEPENDS) || defined(RUN_DEPENDS) || defined(DEPENDS)
+.if defined(EXTRACT_DEPENDS) || defined(PATCH_DEPENDS) || defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || defined(LIB_DEPENDS) || defined(RUN_DEPENDS) || defined(TEST_DEPENDS) || defined(DEPENDS)
@${ALL-DEPENDS-LIST}
.endif
ALL-DEPENDS-LIST= \
checked="${PARENT_CHECKED}"; \
- for dir in $$(${ECHO_CMD} "${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS}" | ${SED} -e 'y/ /\n/' | ${CUT} -f 2 -d ':') $$(${ECHO_CMD} ${DEPENDS} | ${SED} -e 'y/ /\n/' | ${CUT} -f 1 -d ':'); do \
+ for dir in $$(${ECHO_CMD} "${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS} ${TEST_DEPENDS}" | ${SED} -e 'y/ /\n/' | ${CUT} -f 2 -d ':') $$(${ECHO_CMD} ${DEPENDS} | ${SED} -e 'y/ /\n/' | ${CUT} -f 1 -d ':'); do \
if [ -d $$dir ]; then \
if (${ECHO_CMD} $$checked | ${GREP} -qwv "$$dir"); then \
child=$$(cd $$dir; ${MAKE} PARENT_CHECKED="$$checked" all-depends-list); \
@@ -4607,6 +4663,20 @@
fi; \
done | ${SORT} -u
+test-depends-list:
+.if defined(TEST_DEPENDS) || defined(DEPENDS)
+ @${TEST-DEPENDS-LIST}
+.endif
+
+TEST-DEPENDS-LIST= \
+ for dir in $$(${ECHO_CMD} "${TEST_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | ${SORT} -u) $$(${ECHO_CMD} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | ${SORT} -u); do \
+ if [ -d $$dir ]; then \
+ ${ECHO_CMD} $$dir; \
+ else \
+ ${ECHO_MSG} "${PKGNAME}: \"$$dir\" non-existent -- dependency list incomplete" >&2; \
+ fi; \
+ done | ${SORT} -u
+
# Package (recursive runtime) dependency list. Print out both directory names
# and package names.
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list