Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make/unit-tests Add unit-tests for .MAKE.META.IGNORE_*
details: https://anonhg.NetBSD.org/src/rev/1cad32a8fb7f
branches: trunk
changeset: 373662:1cad32a8fb7f
user: sjg <sjg%NetBSD.org@localhost>
date: Thu Feb 23 05:20:45 2023 +0000
description:
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:
usr.bin/make/unit-tests/Makefile | 29 +++-
usr.bin/make/unit-tests/meta-ignore.inc | 61 ++++++++++
usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp | 10 +
usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.mk | 7 +-
usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp | 10 +
usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.mk | 7 +-
usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.exp | 10 +
usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.mk | 7 +-
8 files changed, 116 insertions(+), 25 deletions(-)
diffs (230 lines):
diff -r 4523a1c0b0f6 -r 1cad32a8fb7f usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Thu Feb 23 03:03:58 2023 +0000
+++ b/usr.bin/make/unit-tests/Makefile Thu Feb 23 05:20:45 2023 +0000
@@ -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-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 @@
${: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.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 @@
# 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 -r 4523a1c0b0f6 -r 1cad32a8fb7f usr.bin/make/unit-tests/meta-ignore.inc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/meta-ignore.inc Thu Feb 23 05:20:45 2023 +0000
@@ -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 -r 4523a1c0b0f6 -r 1cad32a8fb7f usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp
--- a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp Thu Feb 23 03:03:58 2023 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp Thu Feb 23 05:20:45 2023 +0000
@@ -1,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 -r 4523a1c0b0f6 -r 1cad32a8fb7f usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.mk
--- a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.mk Thu Feb 23 03:03:58 2023 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.mk Thu Feb 23 05:20:45 2023 +0000
@@ -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 -r 4523a1c0b0f6 -r 1cad32a8fb7f usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp
--- a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp Thu Feb 23 03:03:58 2023 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp Thu Feb 23 05:20:45 2023 +0000
@@ -1,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 -r 4523a1c0b0f6 -r 1cad32a8fb7f usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.mk
--- a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.mk Thu Feb 23 03:03:58 2023 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.mk Thu Feb 23 05:20:45 2023 +0000
@@ -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 -r 4523a1c0b0f6 -r 1cad32a8fb7f usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.exp
--- a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.exp Thu Feb 23 03:03:58 2023 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.exp Thu Feb 23 05:20:45 2023 +0000
@@ -1,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 -r 4523a1c0b0f6 -r 1cad32a8fb7f usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.mk
--- a/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.mk Thu Feb 23 03:03:58 2023 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.mk Thu Feb 23 05:20:45 2023 +0000
@@ -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"
Home |
Main Index |
Thread Index |
Old Index