Module Name:    src
Committed By:   sjg
Date:           Thu Feb 23 05:21:27 UTC 2023

Added Files:
        src/usr.bin/make/unit-tests: meta-ignore.inc

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/meta-ignore.inc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/usr.bin/make/unit-tests/meta-ignore.inc
diff -u /dev/null src/usr.bin/make/unit-tests/meta-ignore.inc:1.1
--- /dev/null	Thu Feb 23 05:21:27 2023
+++ src/usr.bin/make/unit-tests/meta-ignore.inc	Thu Feb 23 05:21:27 2023
@@ -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

Reply via email to