blob: 6e242cf5f978785289f416e1d833b185ec55d929 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# $NetBSD: test.mk,v 1.1 2006/07/05 06:09:15 jlam Exp $
#
# TEST_DIRS is the list of directories in which to perform the build
# process. If the directories are relative paths, then they
# are assumed to be relative to ${WRKSRC}.
#
# TEST_ENV is the shell environment that is exported to the make
# process.
#
# TEST_MAKE_FLAGS is the list of arguments that is passed to the make
# process.
#
TEST_DIRS?= ${BUILD_DIRS}
TEST_ENV+= ${MAKE_ENV}
TEST_MAKE_FLAGS?= ${MAKE_FLAGS}
######################################################################
### test (PUBLIC)
######################################################################
### build is a public target to build the sources from the package.
###
_TEST_TARGETS+= build
_TEST_TARGETS+= acquire-test-lock
_TEST_TARGETS+= ${_TEST_COOKIE}
_TEST_TARGETS+= release-test-lock
.PHONY: test
.if !target(test)
test: ${_TEST_TARGETS}
.endif
.PHONY: acquire-test-lock release-test-lock
acquire-test-lock: acquire-lock
release-test-lock: release-lock
.if !exists(${_TEST_COOKIE})
${_TEST_COOKIE}:
${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-test PKG_PHASE=build
.else
${_TEST_COOKIE}:
@${DO_NADA}
.endif
######################################################################
### real-test (PRIVATE)
######################################################################
### real-test is a helper target onto which one can hook all of the
### targets that do the actual test of the built objects.
###
_REAL_TEST_TARGETS+= test-check-interactive
_REAL_TEST_TARGETS+= test-message
_REAL_TEST_TARGETS+= pre-test
_REAL_TEST_TARGETS+= do-test
_REAL_TEST_TARGETS+= post-test
_REAL_TEST_TARGETS+= test-cookie
_REAL_TEST_TARGETS+= error-check
.PHONY: real-test
real-test: ${_REAL_TEST_TARGETS}
.PHONY: test-message
test-message:
@${PHASE_MSG} "Testing for ${PKGNAME}"
######################################################################
### test-check-interactive (PRIVATE)
######################################################################
### test-check-interactive checks whether we must do an interactive
### test or not.
###
test-check-interactive:
.if !empty(INTERACTIVE_STAGE:Mtest) && defined(BATCH)
@${ERROR_MSG} "The test stage of this package requires user interaction"
@${ERROR_MSG} "Please test manually with:"
@${ERROR_MSG} " \"cd ${.CURDIR} && ${MAKE} test\""
@${TOUCH} ${_INTERACTIVE_COOKIE}
@${FALSE}
.else
@${DO_NADA}
.endif
######################################################################
### pre-test, do-test, post-test (PUBLIC, override)
######################################################################
### {pre,do,post}-test are the heart of the package-customizable
### test targets, and may be overridden within a package Makefile.
###
.PHONY: pre-test do-test post-test
.if !target(do-test)
. if defined(TEST_TARGET) && !empty(TEST_TARGET)
do-test:
. for _dir_ in ${TEST_DIRS}
${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD} \
cd ${WRKSRC} && cd ${_dir_} && \
${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${TEST_MAKE_FLAGS} \
-f ${MAKEFILE} ${TEST_TARGET}
. endfor
. else
do-test:
@${DO_NADA}
. endif
.endif
.if !target(pre-test)
pre-test:
@${DO_NADA}
.endif
.if !target(post-test)
post-test:
@${DO_NADA}
.endif
######################################################################
### test-cookie (PRIVATE)
######################################################################
### test-cookie creates the "test" cookie file.
###
.PHONY: test-cookie
test-cookie:
${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_TEST_COOKIE:H}
${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ${PKGNAME} >> ${_TEST_COOKIE}
|