Module Name:    src
Committed By:   sjg
Date:           Mon Nov 30 18:32:49 UTC 2020

Modified Files:
        src/usr.bin/make/unit-tests: Makefile
Added Files:
        src/usr.bin/make/unit-tests: meta-cmd-cmp.exp meta-cmd-cmp.mk

Log Message:
Add some tests for meta mode


To generate a diff of this commit:
cvs rdiff -u -r1.229 -r1.230 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/meta-cmd-cmp.exp \
    src/usr.bin/make/unit-tests/meta-cmd-cmp.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.229 src/usr.bin/make/unit-tests/Makefile:1.230
--- src/usr.bin/make/unit-tests/Makefile:1.229	Sun Nov 29 18:49:36 2020
+++ src/usr.bin/make/unit-tests/Makefile	Mon Nov 30 18:32:49 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.229 2020/11/29 18:49:36 rillig Exp $
+# $NetBSD: Makefile,v 1.230 2020/11/30 18:32:49 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -188,6 +188,7 @@ TESTS+=		job-flags
 TESTS+=		job-output-long-lines
 TESTS+=		lint
 TESTS+=		make-exported
+TESTS+=		meta-cmd-cmp
 TESTS+=		moderrs
 TESTS+=		modmatch
 TESTS+=		modmisc

Added files:

Index: src/usr.bin/make/unit-tests/meta-cmd-cmp.exp
diff -u /dev/null src/usr.bin/make/unit-tests/meta-cmd-cmp.exp:1.1
--- /dev/null	Mon Nov 30 18:32:49 2020
+++ src/usr.bin/make/unit-tests/meta-cmd-cmp.exp	Mon Nov 30 18:32:49 2020
@@ -0,0 +1,37 @@
+one:
+Building .meta-cmd-cmp.cmp
+Building .meta-cmd-cmp.nocmp
+Building .meta-cmd-cmp.cmp2
+This line not compared FLAGS=
+Skipping meta for .END: .SPECIAL
+two:
+`.meta-cmd-cmp.cmp' is up to date.
+`.meta-cmd-cmp.nocmp' is up to date.
+.meta-cmd-cmp.cmp2.meta: 3: cannot compare command using .OODATE
+`.meta-cmd-cmp.cmp2' is up to date.
+Skipping meta for .END: .SPECIAL
+change1:
+.meta-cmd-cmp.cmp.meta: 2: a build command has changed
+@echo FLAGS= > .meta-cmd-cmp.cmp
+vs
+@echo FLAGS=changed > .meta-cmd-cmp.cmp
+Building .meta-cmd-cmp.cmp
+`.meta-cmd-cmp.nocmp' is up to date.
+.meta-cmd-cmp.cmp2.meta: 3: cannot compare command using .OODATE
+`.meta-cmd-cmp.cmp2' is up to date.
+Skipping meta for .END: .SPECIAL
+change2:
+.meta-cmd-cmp.cmp.meta: 2: a build command has changed
+@echo FLAGS=changed > .meta-cmd-cmp.cmp
+vs
+@echo FLAGS= > .meta-cmd-cmp.cmp
+Building .meta-cmd-cmp.cmp
+`.meta-cmd-cmp.nocmp' is up to date.
+.meta-cmd-cmp.cmp2.meta: 2: a build command has changed
+@echo FLAGS2= > .meta-cmd-cmp.cmp2
+vs
+@echo FLAGS2=changed > .meta-cmd-cmp.cmp2
+Building .meta-cmd-cmp.cmp2
+This line not compared FLAGS=
+Skipping meta for .END: .SPECIAL
+exit status 0
Index: src/usr.bin/make/unit-tests/meta-cmd-cmp.mk
diff -u /dev/null src/usr.bin/make/unit-tests/meta-cmd-cmp.mk:1.1
--- /dev/null	Mon Nov 30 18:32:49 2020
+++ src/usr.bin/make/unit-tests/meta-cmd-cmp.mk	Mon Nov 30 18:32:49 2020
@@ -0,0 +1,49 @@
+# $NetBSD: meta-cmd-cmp.mk,v 1.1 2020/11/30 18:32:49 sjg Exp $
+#
+# Tests META_MODE command line comparison
+#
+
+.MAIN: all
+
+.MAKE.MODE= meta verbose silent=yes curdirok=yes
+tf:= .${.PARSEFILE:R}
+
+.if ${.TARGETS:Nall} == ""
+all: prep one two change1 change2 post
+
+CLEANFILES= ${tf}*
+
+prep post: .PHONY
+	@rm -f ${CLEANFILES}
+
+.endif
+
+FLAGS?=
+FLAGS2?=
+
+tests= ${tf}.cmp ${tf}.nocmp ${tf}.cmp2
+
+${tf}.cmp:
+	@echo FLAGS=${FLAGS:Uempty} > $@
+
+${tf}.nocmp: .NOMETA_CMP
+	@echo FLAGS=${FLAGS:Uempty} > $@
+
+# a line containing ${.OODATE} will not be compared
+# this allows the trick below
+${tf}.cmp2:
+	@echo FLAGS2=${FLAGS2:Uempty} > $@
+	@echo This line not compared FLAGS=${FLAGS:Uempty} ${.OODATE:MNOMETA_CMP}
+
+# these do the same 
+one two: .PHONY
+	@echo $@:
+	@${.MAKE} -dM -r -C ${.CURDIR} -f ${MAKEFILE} ${tests}
+
+change1: .PHONY
+	@echo $@:
+	@${.MAKE} -dM -r -C ${.CURDIR} -f ${MAKEFILE} FLAGS=changed ${tests}
+
+change2: .PHONY
+	@echo $@:
+	@${.MAKE} -dM -r -C ${.CURDIR} -f ${MAKEFILE} FLAGS2=changed ${tests}

Reply via email to