Module Name: src
Committed By: rillig
Date: Mon Dec 7 22:27:56 UTC 2020
Modified Files:
src/usr.bin/make: test-variants.sh
src/usr.bin/make/unit-tests: Makefile sh-dots.exp sh-meta-chars.mk
Log Message:
make(1): normalize output of test sh-dots for non-native mode
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/test-variants.sh
cvs rdiff -u -r1.239 -r1.240 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/sh-dots.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/sh-meta-chars.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/test-variants.sh
diff -u src/usr.bin/make/test-variants.sh:1.7 src/usr.bin/make/test-variants.sh:1.8
--- src/usr.bin/make/test-variants.sh:1.7 Sun Nov 29 21:27:08 2020
+++ src/usr.bin/make/test-variants.sh Mon Dec 7 22:27:56 2020
@@ -1,5 +1,5 @@
#! /bin/sh
-# $NetBSD: test-variants.sh,v 1.7 2020/11/29 21:27:08 rillig Exp $
+# $NetBSD: test-variants.sh,v 1.8 2020/12/07 22:27:56 rillig Exp $
#
# Build several variants of make and run the tests on them.
#
@@ -149,6 +149,12 @@ testcase USER_CFLAGS="-ansi" USER_CPPFLA
#
testcase USER_CPPFLAGS="-DNDEBUG"
+# Only in native mode, make dares to use a shortcut in Compat_RunCommand
+# that circumvents the shell and instead calls execvp directly.
+# Another effect is that the shell is run with -q, which prevents the
+# -x and -v flags from echoing the commands from profile files.
+testcase USER_CPPFLAGS="-UMAKE_NATIVE -DHAVE_STRERROR -DHAVE_SETENV -DHAVE_VSNPRINTF"
+
# Running the code coverage using gcov takes a long time. Most of this
# time is spent in gcov_read_unsigned because gcov_open sets the .gcda
# file to unbuffered, which means that every single byte needs its own
Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.239 src/usr.bin/make/unit-tests/Makefile:1.240
--- src/usr.bin/make/unit-tests/Makefile:1.239 Mon Dec 7 21:35:43 2020
+++ src/usr.bin/make/unit-tests/Makefile Mon Dec 7 22:27:56 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.239 2020/12/07 21:35:43 rillig Exp $
+# $NetBSD: Makefile,v 1.240 2020/12/07 22:27:56 rillig Exp $
#
# Unit tests for make(1)
#
@@ -474,7 +474,11 @@ SED_CMDS.opt-debug-jobs+= -e 's,JobFinis
SED_CMDS.opt-debug-jobs+= -e 's,Command: ${.SHELL:T},Command: <shell>,'
# The "-q" may be there or not, see jobs.c, variable shells.
SED_CMDS.opt-debug-jobs+= -e 's,^\(.Command: <shell>\) -q,\1,'
-SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,<normalized: ...: not found>,'
+# For Compat_RunCommand, useShell == FALSE.
+SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,<not found: ...>,'
+# For Compat_RunCommand, useShell == TRUE.
+SED_CMDS.sh-dots+= -e 's,^make: exec(\(.*\)) failed (.*)$$,<not found: \1>,'
+SED_CMDS.sh-dots+= -e 's,^\(\*\*\* Error code \)[1-9][0-9]*,\1<nonzero>,'
SED_CMDS.suff-main+= ${STD_SED_CMDS.dg1}
SED_CMDS.suff-main-several+= ${STD_SED_CMDS.dg1}
SED_CMDS.suff-transform-debug+= ${STD_SED_CMDS.dg1}
Index: src/usr.bin/make/unit-tests/sh-dots.exp
diff -u src/usr.bin/make/unit-tests/sh-dots.exp:1.4 src/usr.bin/make/unit-tests/sh-dots.exp:1.5
--- src/usr.bin/make/unit-tests/sh-dots.exp:1.4 Sun Oct 25 22:04:24 2020
+++ src/usr.bin/make/unit-tests/sh-dots.exp Mon Dec 7 22:27:56 2020
@@ -1,19 +1,19 @@
first first
hidden hidden
-make: exec(...) failed (No such file or directory)
-*** Error code 1 (ignored)
+<not found: ...>
+*** Error code <nonzero> (ignored)
hidden delayed hidden
repeated repeated
commented commented
... # Run the below commands later
-<normalized: ...: not found>
-*** Error code 127 (ignored)
+<not found: ...>
+*** Error code <nonzero> (ignored)
commented delayed commented
indirect regular
indirect-space regular
...
-make: exec(...) failed (No such file or directory)
-*** Error code 1 (ignored)
+<not found: ...>
+*** Error code <nonzero> (ignored)
indirect-space deferred
first delayed first
repeated delayed repeated
Index: src/usr.bin/make/unit-tests/sh-meta-chars.mk
diff -u src/usr.bin/make/unit-tests/sh-meta-chars.mk:1.3 src/usr.bin/make/unit-tests/sh-meta-chars.mk:1.4
--- src/usr.bin/make/unit-tests/sh-meta-chars.mk:1.3 Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/sh-meta-chars.mk Mon Dec 7 22:27:56 2020
@@ -1,4 +1,4 @@
-# $NetBSD: sh-meta-chars.mk,v 1.3 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: sh-meta-chars.mk,v 1.4 2020/12/07 22:27:56 rillig Exp $
#
# Tests for running shell commands that contain meta-characters.
#
@@ -9,7 +9,16 @@
# See also:
# Compat_RunCommand, useShell
-# TODO: Implementation
-
all:
- @:;
+
+# The command "exit 0" contains no special characters, therefore it is
+# run directly via execv, but only if MAKE_NATIVE is defined.
+USING_EXEC!= { echo 'all:; exit 0' | ${MAKE} -r -f - 1>/dev/null 2>&1; } \
+ && echo yes || echo no
+
+# It's hard to do any useful tests that result in the same output.
+# See SED_CMDS.sh-dots, which normalizes the test output for the specific
+# case of the special command '...'.
+.if ${USING_EXEC} != "yes" && ${USING_EXEC} != "no"
+. error
+.endif