Module Name:    src
Committed By:   rillig
Date:           Thu Jan 20 19:16:25 UTC 2022

Modified Files:
        src/usr.bin/make/unit-tests: dep-duplicate.exp dep-duplicate.mk

Log Message:
tests/make: refine test for wrong diagnostic line

To trigger the faulty code path, the file where the targets gets its
first command must be included via its relative path.  That was the case
when running 'cd usr.bin/make && make test' but not when running the
tests via ATF.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/dep-duplicate.exp \
    src/usr.bin/make/unit-tests/dep-duplicate.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/dep-duplicate.exp
diff -u src/usr.bin/make/unit-tests/dep-duplicate.exp:1.1 src/usr.bin/make/unit-tests/dep-duplicate.exp:1.2
--- src/usr.bin/make/unit-tests/dep-duplicate.exp:1.1	Wed Jan 19 22:10:41 2022
+++ src/usr.bin/make/unit-tests/dep-duplicate.exp	Thu Jan 20 19:16:25 2022
@@ -1,4 +1,4 @@
 make: "dep-duplicate.inc" line 1: warning: duplicate script for target "all" ignored
-make: "dep-duplicate.inc" line 15: warning: using previous script for "all" defined here
-first
+make: "dep-duplicate.inc" line 3: warning: using previous script for "all" defined here
+main-output
 exit status 0
Index: src/usr.bin/make/unit-tests/dep-duplicate.mk
diff -u src/usr.bin/make/unit-tests/dep-duplicate.mk:1.1 src/usr.bin/make/unit-tests/dep-duplicate.mk:1.2
--- src/usr.bin/make/unit-tests/dep-duplicate.mk:1.1	Wed Jan 19 22:10:41 2022
+++ src/usr.bin/make/unit-tests/dep-duplicate.mk	Thu Jan 20 19:16:25 2022
@@ -1,21 +1,31 @@
-# $NetBSD: dep-duplicate.mk,v 1.1 2022/01/19 22:10:41 rillig Exp $
+# $NetBSD: dep-duplicate.mk,v 1.2 2022/01/20 19:16:25 rillig Exp $
 #
 # Test for a target whose commands are defined twice.  This generates a
 # warning, not an error, so ensure that the correct commands are kept.
 #
 # Also ensure that the diagnostics mention the correct file in case of
-# included files.  This particular case had been broken in parse.c 1.231 from
-# 2018-12-22.
+# included files.  Since parse.c 1.231 from 2018-12-22 and before parse.c
+# 1.653 from 2022-01-20, the wrong filename had been printed if the file of
+# the first commands section was in a file that was included by its relative
+# path.
 
-# expect: make: "dep-duplicate.inc" line 15: warning: using previous script for "all" defined here
-# FIXME: The file "dep-duplicate.inc" has no line 15.
+# expect: make: "dep-duplicate.inc" line 3: warning: using previous script for "all" defined here
+# FIXME: The file "dep-duplicate.inc" has no line 3.
 
-# expect: first
 all: .PHONY
-	@echo first
+	@exec > dep-duplicate.main; \
+	echo '# empty line 1'; \
+	echo '# empty line 2'; \
+	echo 'all:; @echo main-output'; \
+	echo '.include "dep-duplicate.inc"'
 
-_!=	echo 'all:;echo second' > dep-duplicate.inc
-.include "${.CURDIR}/dep-duplicate.inc"
+	@exec > dep-duplicate.inc; \
+	echo 'all:; @echo inc-output'
 
-.END:
+	# The main file must be specified using a relative path, just like the
+	# default 'makefile' or 'Makefile', to produce the same result when
+	# run via ATF or 'make test'.
+	@${MAKE} -r -f dep-duplicate.main
+
+	@rm -f dep-duplicate.main
 	@rm -f dep-duplicate.inc

Reply via email to