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 make(1): add test for backslash cont...



details:   https://anonhg.NetBSD.org/src/rev/9431f14cf071
branches:  trunk
changeset: 947599:9431f14cf071
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Dec 19 12:40:00 2020 +0000

description:
make(1): add test for backslash continuation lines in .for loops

This ensures that the line numbers for messages are the expected onces
in .for loops.

While experimenting with the backslash continuation lines, I noticed
that the reported line numbers for these are based on the number of
completely parsed physical lines, which nicely cancels out the + 1 that
has to be added for producing human-readable 1-based line numbers.  It
would be more correct to report the parse errors on the first affected
line.

diffstat:

 usr.bin/make/unit-tests/directive-for-lines.exp |  12 ++++++------
 usr.bin/make/unit-tests/directive-for-lines.mk  |  18 ++++++++++++------
 usr.bin/make/unit-tests/directive-info.exp      |   1 +
 usr.bin/make/unit-tests/directive-info.mk       |  10 +++++++++-
 4 files changed, 28 insertions(+), 13 deletions(-)

diffs (92 lines):

diff -r c341f61d71c6 -r 9431f14cf071 usr.bin/make/unit-tests/directive-for-lines.exp
--- a/usr.bin/make/unit-tests/directive-for-lines.exp   Sat Dec 19 12:24:46 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-for-lines.exp   Sat Dec 19 12:40:00 2020 +0000
@@ -1,9 +1,9 @@
-make: "directive-for-lines.mk" line 18: expect 18
-make: "directive-for-lines.mk" line 18: expect 18
-make: "directive-for-lines.mk" line 24: expect 24
-make: "directive-for-lines.mk" line 18: expect 18
-make: "directive-for-lines.mk" line 18: expect 18
-make: "directive-for-lines.mk" line 24: expect 24
+make: "directive-for-lines.mk" line 23: expect 23
+make: "directive-for-lines.mk" line 23: expect 23
+make: "directive-for-lines.mk" line 30: expect 30
+make: "directive-for-lines.mk" line 23: expect 23
+make: "directive-for-lines.mk" line 23: expect 23
+make: "directive-for-lines.mk" line 30: expect 30
 make: no target to make.
 
 make: stopped in unit-tests
diff -r c341f61d71c6 -r 9431f14cf071 usr.bin/make/unit-tests/directive-for-lines.mk
--- a/usr.bin/make/unit-tests/directive-for-lines.mk    Sat Dec 19 12:24:46 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-for-lines.mk    Sat Dec 19 12:40:00 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-lines.mk,v 1.2 2020/12/19 12:24:46 rillig Exp $
+# $NetBSD: directive-for-lines.mk,v 1.3 2020/12/19 12:40:00 rillig Exp $
 #
 # Tests for the line numbers that are reported in .for loops.
 #
@@ -9,18 +9,24 @@
 
 .for outer in a b
 
-# comment
+# comment \
+# continued comment
 
 .for inner in 1 2
 
-# comment
+# comment \
+# continued comment
 
-.info expect 18
+VAR= \
+       multi-line
+
+.info expect 23
 
 .endfor
 
-# comment
+# comment \
+# continued comment
 
-.info expect 24
+.info expect 30
 
 .endfor
diff -r c341f61d71c6 -r 9431f14cf071 usr.bin/make/unit-tests/directive-info.exp
--- a/usr.bin/make/unit-tests/directive-info.exp        Sat Dec 19 12:24:46 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-info.exp        Sat Dec 19 12:40:00 2020 +0000
@@ -9,6 +9,7 @@
 make: "directive-info.mk" line 19: Unknown directive "info"
 make: "directive-info.mk" line 22: Unknown directive "info-message"
 make: "directive-info.mk" line 23: no-target: no-source
+make: "directive-info.mk" line 32: expect line 30 for multi-line message
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r c341f61d71c6 -r 9431f14cf071 usr.bin/make/unit-tests/directive-info.mk
--- a/usr.bin/make/unit-tests/directive-info.mk Sat Dec 19 12:24:46 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-info.mk Sat Dec 19 12:40:00 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: directive-info.mk,v 1.6 2020/12/13 01:10:22 rillig Exp $
+# $NetBSD: directive-info.mk,v 1.7 2020/12/19 12:40:00 rillig Exp $
 #
 # Tests for the .info directive.
 
@@ -23,5 +23,13 @@
 .info no-target: no-source     # This is a .info directive, not a dependency.
 # See directive.mk for more tests of this kind.
 
+# Since at least 2002-01-01, the line number that is used in error messages
+# and the .info directives is the number of completely read lines.  For the
+# following multi-line directive, this means that the reported line number is
+# the one of the last line, not the first line.
+.info expect line 30 for\
+       multi$\
+       -line message
+
 all:
        @:;



Home | Main Index | Thread Index | Old Index