summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2022-01-20 19:16:25 +0000
committerrillig <rillig@NetBSD.org>2022-01-20 19:16:25 +0000
commit49866fb3aa00b4b8a489ea80681c45c3d55cf1bc (patch)
tree003275315b7a66fc9e88ebe4848b66a39bb3de68 /usr.bin/make
parent0d62f6f5baa68819bff03207d2de6728fc94b418 (diff)
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.
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/unit-tests/dep-duplicate.exp4
-rw-r--r--usr.bin/make/unit-tests/dep-duplicate.mk30
2 files changed, 22 insertions, 12 deletions
diff --git a/usr.bin/make/unit-tests/dep-duplicate.exp b/usr.bin/make/unit-tests/dep-duplicate.exp
index 74c53516b52..2d93c69074e 100644
--- a/usr.bin/make/unit-tests/dep-duplicate.exp
+++ b/usr.bin/make/unit-tests/dep-duplicate.exp
@@ -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
diff --git a/usr.bin/make/unit-tests/dep-duplicate.mk b/usr.bin/make/unit-tests/dep-duplicate.mk
index d6dabee87e0..369a4606b92 100644
--- a/usr.bin/make/unit-tests/dep-duplicate.mk
+++ b/usr.bin/make/unit-tests/dep-duplicate.mk
@@ -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