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 the -de option



details:   https://anonhg.NetBSD.org/src/rev/fb18f41beeb5
branches:  trunk
changeset: 938303:fb18f41beeb5
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Sep 06 04:35:03 2020 +0000

description:
make(1): add test for the -de option

diffstat:

 usr.bin/make/unit-tests/opt-debug-errors.exp |  33 ++++++++++++++++++++++
 usr.bin/make/unit-tests/opt-debug-errors.mk  |  41 +++++++++++++++++++++++++--
 2 files changed, 70 insertions(+), 4 deletions(-)

diffs (88 lines):

diff -r 699d03df370a -r fb18f41beeb5 usr.bin/make/unit-tests/opt-debug-errors.exp
--- a/usr.bin/make/unit-tests/opt-debug-errors.exp      Sun Sep 06 02:34:30 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-debug-errors.exp      Sun Sep 06 04:35:03 2020 +0000
@@ -1,1 +1,34 @@
+echo '3   spaces'; false
+3   spaces
+
+*** Failed target:  fail-spaces
+*** Failed command: echo '3 spaces'; false
+*** Error code 1 (continuing)
+echo \  indented; false
+  indented
+
+*** Failed target:  fail-escaped-space
+*** Failed command: echo \ indented; false
+*** Error code 1 (continuing)
+echo 'line1
+line2'; false
+line1
+line2
+
+*** Failed target:  fail-newline
+*** Failed command: echo 'line1 line2'; false
+*** Error code 1 (continuing)
+echo 'line1 line2'; false
+line1 line2
+
+*** Failed target:  fail-multiline
+*** Failed command: echo 'line1 line2'; false
+*** Error code 1 (continuing)
+echo   'word1'                                                  'word2'; false
+word1 word2
+
+*** Failed target:  fail-multiline-intention
+*** Failed command: echo 'word1' 'word2'; false
+*** Error code 1 (continuing)
+`all' not remade because of errors.
 exit status 0
diff -r 699d03df370a -r fb18f41beeb5 usr.bin/make/unit-tests/opt-debug-errors.mk
--- a/usr.bin/make/unit-tests/opt-debug-errors.mk       Sun Sep 06 02:34:30 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-debug-errors.mk       Sun Sep 06 04:35:03 2020 +0000
@@ -1,9 +1,42 @@
-# $NetBSD: opt-debug-errors.mk,v 1.1 2020/09/05 06:20:51 rillig Exp $
+# $NetBSD: opt-debug-errors.mk,v 1.2 2020/09/06 04:35:03 rillig Exp $
 #
 # Tests for the -de command line option, which adds debug logging for
 # failed commands and targets.
 
-# TODO: Implementation
+.MAKEFLAGS: -de
+
+all: fail-spaces
+all: fail-escaped-space
+all: fail-newline
+all: fail-multiline
+all: fail-multiline-intention
+
+# XXX: The debug output folds the spaces, showing '3 spaces' instead of
+# the correct '3   spaces'.
+fail-spaces:
+       echo '3   spaces'; false
+
+# XXX: The debug output folds the spaces, showing 'echo \ indented' instead
+# of the correct 'echo \  indented'.
+fail-escaped-space:
+       echo \  indented; false
 
-all:
-       @:;
+# XXX: A newline is turned into an ordinary space in the debug log.
+fail-newline:
+       echo 'line1${.newline}line2'; false
+
+# The line continuations in multiline commands are turned into an ordinary
+# space before the command is actually run.
+fail-multiline:
+       echo 'line1\
+               line2'; false
+
+# It is a common style to align the continuation backslashes at the right
+# of the lines, usually at column 73.  All spaces before the continuation
+# backslash are preserved and are usually outside a shell word and thus
+# irrelevant.  Having these spaces collapsed makes sense to show the command
+# in its condensed form.
+#
+fail-multiline-intention:
+       echo    'word1'                                                 \
+               'word2'; false



Home | Main Index | Thread Index | Old Index