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 tests/make: refine test for wrong di...



details:   https://anonhg.NetBSD.org/src/rev/a3a8b6e94158
branches:  trunk
changeset: 359745:a3a8b6e94158
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jan 20 19:16:25 2022 +0000

description:
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:

 usr.bin/make/unit-tests/dep-duplicate.exp |   4 ++--
 usr.bin/make/unit-tests/dep-duplicate.mk  |  30 ++++++++++++++++++++----------
 2 files changed, 22 insertions(+), 12 deletions(-)

diffs (55 lines):

diff -r 93b81358d015 -r a3a8b6e94158 usr.bin/make/unit-tests/dep-duplicate.exp
--- a/usr.bin/make/unit-tests/dep-duplicate.exp Thu Jan 20 14:46:06 2022 +0000
+++ b/usr.bin/make/unit-tests/dep-duplicate.exp Thu Jan 20 19:16:25 2022 +0000
@@ -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 -r 93b81358d015 -r a3a8b6e94158 usr.bin/make/unit-tests/dep-duplicate.mk
--- a/usr.bin/make/unit-tests/dep-duplicate.mk  Thu Jan 20 14:46:06 2022 +0000
+++ b/usr.bin/make/unit-tests/dep-duplicate.mk  Thu Jan 20 19:16:25 2022 +0000
@@ -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



Home | Main Index | Thread Index | Old Index