diff options
| author | sjg <sjg@NetBSD.org> | 2023-02-23 05:20:45 +0000 |
|---|---|---|
| committer | sjg <sjg@NetBSD.org> | 2023-02-23 05:20:45 +0000 |
| commit | aba449a55bf91b44bc68f542edd9afa341962b89 (patch) | |
| tree | 990ff8664f8cf155296254c4eda1af7e3abe9f56 /usr.bin/make | |
| parent | 38ba41b8b97488e6d374932f0acb8cefd3bdd298 (diff) | |
Add unit-tests for .MAKE.META.IGNORE_*
These unit-tests should only be run if TEST_MAKE
has a valid .MAKE.PATH_FILEMON to indicate that filemon is
supported.
All three tests use the same meta-ignore.inc
which runs three sub-makes
one to initialize the target .meta file
two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER}
three to verify that without .MAKE.META.IGNORE_* the target is out of date.
Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in
.OBJDIR
Diffstat (limited to 'usr.bin/make')
8 files changed, 116 insertions, 25 deletions
diff --git a/usr.bin/make/unit-tests/Makefile b/usr.bin/make/unit-tests/Makefile index 6b6def1883e..63544a9e655 100644 --- a/usr.bin/make/unit-tests/Makefile +++ b/usr.bin/make/unit-tests/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.331 2023/01/24 00:24:02 sjg Exp $ +# $NetBSD: Makefile,v 1.332 2023/02/23 05:20:45 sjg Exp $ # # Unit tests for make(1) # @@ -405,12 +405,14 @@ TESTS+= varname-dot-make-makefiles TESTS+= varname-dot-make-meta-bailiwick TESTS+= varname-dot-make-meta-created TESTS+= varname-dot-make-meta-files +.if ${.MAKE.PATH_FILEMON:Uno:Nktrace:N/dev*} == "" TESTS+= varname-dot-make-meta-ignore_filter TESTS+= varname-dot-make-meta-ignore_paths TESTS+= varname-dot-make-meta-ignore_patterns +TESTS+= varname-dot-make-path_filemon +.endif TESTS+= varname-dot-make-meta-prefix TESTS+= varname-dot-make-mode -TESTS+= varname-dot-make-path_filemon TESTS+= varname-dot-make-pid TESTS+= varname-dot-make-ppid TESTS+= varname-dot-make-save_dollars @@ -501,6 +503,10 @@ SED_CMDS.job-output-long-lines= \ ${:D marker should always be at the beginning of the line. } \ -e '/^aa*--- job-b ---$$/d' \ -e '/^bb*--- job-a ---$$/d' + +# meta line numbers can vary based on filemon implementation +SED_CMDS.meta-ignore= -e 's,\(\.meta:\) [1-9][0-9]*:,\1 <line>:,' + SED_CMDS.opt-chdir= -e 's,\(nonexistent\).[1-9][0-9]*,\1,' SED_CMDS.opt-debug-graph1= ${STD_SED_CMDS.dg1} SED_CMDS.opt-debug-graph2= ${STD_SED_CMDS.dg2} @@ -533,6 +539,9 @@ SED_CMDS.var-op-shell+= -e '/command/s,No such.*,not found,' SED_CMDS.vardebug+= -e 's,${.SHELL},</path/to/shell>,' SED_CMDS.varmod-subst-regex+= ${STD_SED_CMDS.regex} SED_CMDS.varparse-errors+= ${STD_SED_CMDS.timestamp} +SED_CMDS.varname-dot-make-meta-ignore_filter+= ${SED_CMDS.meta-ignore} +SED_CMDS.varname-dot-make-meta-ignore_paths+= ${SED_CMDS.meta-ignore} +SED_CMDS.varname-dot-make-meta-ignore_patterns+= ${SED_CMDS.meta-ignore} SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,' SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,' SED_CMDS.varname-dot-shell= -e 's, = /[^ ]*, = (details omitted),g' @@ -713,23 +722,23 @@ LIMIT_RESOURCES?= : # Postprocess the test output to make the output platform-independent. # -# always pretend .MAKE was called 'make' -_SED_CMDS+= -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,' -_SED_CMDS+= -e 's,${TEST_MAKE:S,.,\\.,g},make,' -_SED_CMDS+= -e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,' -# replace anything after 'stopped in' with unit-tests +# Replace anything after 'stopped in' with unit-tests _SED_CMDS+= -e '/stopped/s, /.*, unit-tests,' # Allow the test files to be placed anywhere. _SED_CMDS+= -e 's,\(\.PARSEDIR}\) = `'"/[^']*'"',\1 = <some-dir>,' _SED_CMDS+= -e 's,\(\.INCLUDEDFROMDIR}\) = `'"/[^']*'"',\1 = <some-dir>,' -_SED_CMDS+= -e 's,${TMPDIR},<tmpdir>,g' +_SED_CMDS+= -e 's,${TMPDIR},<tmpdir>,g' -e 's,${TMPDIR:tA},<tmpdir>,g' # canonicalize ${.OBJDIR} and ${.CURDIR} +_SED_CMDS+= -e 's,${.CURDIR},<curdir>,g' .if ${.OBJDIR} != ${.CURDIR} # yes this is inaccurate but none of the tests expect <objdir> anywhere # which we get depending on how MAKEOBJDIR is set. -_SED_CMDS+= -e 's,${.OBJDIR},<curdir>,g' +_SED_CMDS+= -e 's,${.OBJDIR},<curdir>,g' -e 's,${.OBJDIR:tA},<curdir>,g' .endif -_SED_CMDS+= -e 's,${.CURDIR},<curdir>,g' +# always pretend .MAKE was called 'make' +_SED_CMDS+= -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,' +_SED_CMDS+= -e 's,${TEST_MAKE:S,.,\\.,g},make,' +_SED_CMDS+= -e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,' _SED_CMDS+= -e 's,<curdir>/,,g' _SED_CMDS+= -e 's,${UNIT_TESTS:S,.,\\.,g}/,,g' _SED_CMDS+= -e '/MAKE_VERSION/d' diff --git a/usr.bin/make/unit-tests/meta-ignore.inc b/usr.bin/make/unit-tests/meta-ignore.inc new file mode 100644 index 00000000000..f2b8a92e5d0 --- /dev/null +++ b/usr.bin/make/unit-tests/meta-ignore.inc @@ -0,0 +1,61 @@ +# $NetBSD: meta-ignore.inc,v 1.1 2023/02/23 05:21:27 sjg Exp $ + +# common logic for testing .MAKE.META.IGNORE_* + +# we want a directory outside of .OBJDIR to drop a file +# that our meta file refers to. +IGNORE:= ${TMPDIR}/ignore +OBJ:= ${TMPDIR}/obj + +# this is always ignored so make sure it isn't used above +TMPDIR= /tmp/nothanks + +all: one two three + +setup: + @mkdir -p ${IGNORE} ${OBJ} + @echo > ${IGNORE}/check + @rm -f ${OBJ}/check-ignore + +makefile:= ${.INCLUDEDFROMDIR}/${.INCLUDEDFROMFILE} +TEST:= ${.INCLUDEDFROMFILE:R} + +DESC.one= Initialize check-ignore.meta +DESC.two= Use .MAKE.META.IGNORE_* - check-ignore is up to date +DESC.three= Skip .MAKE.META.IGNORE_* - check-ignore is out of date + +# just in case someone runs us with -jN +.ORDER: one two three +one two three: .MAKE setup + @echo "${DESC.${.TARGET}}"; \ + ${MAKE} -C ${.CURDIR} -f ${makefile} check-ignore parent=${.TARGET} + +.if make(check-ignore) +.MAKEFLAGS: -dM +.MAKE.MODE = meta verbose silent=yes +.OBJDIR: ${OBJ} +.if ${parent} == "two" +.if ${TEST:M*ignore_paths} != "" +# this is a prefix list - any path that matches +# one of these prefixes will be ignored +.MAKE.META.IGNORE_PATHS = ${IGNORE} +.elif ${TEST:M*ignore_patterns} != "" +# more flexible but more expensive +# this example is equivalent to M*/ignore/* +# a match means ignore +.MAKE.META.IGNORE_PATTERNS = */ignore/* +.elif ${TEST:M*ignore_filter} != "" +# this is the most flexible, but also most expensive +# if this expands to nothing - ignore the path +.MAKE.META.IGNORE_FILTER = N${IGNORE}/* +.endif +.endif + +# : < just reads from ${IGNORE}/check +# so that our filemon trace will have a reference to it +# we ensure it is always newer than the target. +check-ignore: .META .NOPATH + @: < ${IGNORE}/check > ${.TARGET} + @sleep 1; echo ${.TARGET} > ${IGNORE}/check + +.endif diff --git a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp index 39a9383953d..caeffc18bc2 100644 --- a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp +++ b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp @@ -1 +1,11 @@ +Initialize check-ignore.meta +Building <tmpdir>/obj/check-ignore +Skipping meta for .END: .SPECIAL +Use .MAKE.META.IGNORE_* - check-ignore is up to date +`check-ignore' is up to date. +Skipping meta for .END: .SPECIAL +Skip .MAKE.META.IGNORE_* - check-ignore is out of date +<tmpdir>/obj/check-ignore.meta: <line>: file '<tmpdir>/ignore/check' is newer than the target... +Building <tmpdir>/obj/check-ignore +Skipping meta for .END: .SPECIAL exit status 0 diff --git a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.mk b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.mk index c41aec4acdf..0adf6a20285 100644 --- a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.mk +++ b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.mk @@ -1,8 +1,5 @@ -# $NetBSD: varname-dot-make-meta-ignore_filter.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ +# $NetBSD: varname-dot-make-meta-ignore_filter.mk,v 1.3 2023/02/23 05:20:45 sjg Exp $ # # Tests for the special .MAKE.META.IGNORE_FILTER variable. -# TODO: Implementation - -all: - @:; +.include "meta-ignore.inc" diff --git a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp index 39a9383953d..caeffc18bc2 100644 --- a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp +++ b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp @@ -1 +1,11 @@ +Initialize check-ignore.meta +Building <tmpdir>/obj/check-ignore +Skipping meta for .END: .SPECIAL +Use .MAKE.META.IGNORE_* - check-ignore is up to date +`check-ignore' is up to date. +Skipping meta for .END: .SPECIAL +Skip .MAKE.META.IGNORE_* - check-ignore is out of date +<tmpdir>/obj/check-ignore.meta: <line>: file '<tmpdir>/ignore/check' is newer than the target... +Building <tmpdir>/obj/check-ignore +Skipping meta for .END: .SPECIAL exit status 0 diff --git a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.mk b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.mk index 4ae34f51608..2c58849af0b 100644 --- a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.mk +++ b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.mk @@ -1,8 +1,5 @@ -# $NetBSD: varname-dot-make-meta-ignore_paths.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ +# $NetBSD: varname-dot-make-meta-ignore_paths.mk,v 1.3 2023/02/23 05:20:45 sjg Exp $ # # Tests for the special .MAKE.META.IGNORE_PATHS variable. -# TODO: Implementation - -all: - @:; +.include "meta-ignore.inc" diff --git a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.exp b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.exp index 39a9383953d..caeffc18bc2 100644 --- a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.exp +++ b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.exp @@ -1 +1,11 @@ +Initialize check-ignore.meta +Building <tmpdir>/obj/check-ignore +Skipping meta for .END: .SPECIAL +Use .MAKE.META.IGNORE_* - check-ignore is up to date +`check-ignore' is up to date. +Skipping meta for .END: .SPECIAL +Skip .MAKE.META.IGNORE_* - check-ignore is out of date +<tmpdir>/obj/check-ignore.meta: <line>: file '<tmpdir>/ignore/check' is newer than the target... +Building <tmpdir>/obj/check-ignore +Skipping meta for .END: .SPECIAL exit status 0 diff --git a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.mk b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.mk index ea9fc49f171..d3d6e065857 100644 --- a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.mk +++ b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.mk @@ -1,8 +1,5 @@ -# $NetBSD: varname-dot-make-meta-ignore_patterns.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ +# $NetBSD: varname-dot-make-meta-ignore_patterns.mk,v 1.3 2023/02/23 05:20:45 sjg Exp $ # # Tests for the special .MAKE.META.IGNORE_PATTERNS variable. -# TODO: Implementation - -all: - @:; +.include "meta-ignore.inc" |
