tests/make: add tests for whitespace in leading '@+-'

This commit is contained in:
rillig 2023-01-19 19:55:27 +00:00
parent 2e751aba0e
commit 6d4c6645b2
8 changed files with 46 additions and 7 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: test-variants.mk,v 1.4 2022/05/08 19:19:11 rillig Exp $
# $NetBSD: test-variants.mk,v 1.5 2023/01/19 19:55:27 rillig Exp $
#
# Build several variants of make and run the tests on them.
#
@ -10,7 +10,7 @@
usage:
@echo 'usage: ${MAKE} -f ${MAKEFILE} list'
@echo ' ${MAKE} -f ${MAKEFILE} all'
@echo ' ${MAKE} -f ${MAKEFILE} test...'
@echo ' ${MAKE} -f ${MAKEFILE} <test>...'
TESTS+= default

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.327 2022/09/25 12:32:56 rillig Exp $
# $NetBSD: Makefile,v 1.328 2023/01/19 19:55:27 rillig Exp $
#
# Unit tests for make(1)
#
@ -527,6 +527,7 @@ 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.sh-errctl= ${STD_SED_CMDS.dj}
SED_CMDS.sh-flags= ${STD_SED_CMDS.hide-from-output}
SED_CMDS.sh-leading-hyphen= ${STD_SED_CMDS.shell}
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}
@ -613,9 +614,11 @@ STD_SED_CMDS.hide-from-output= \
# bash 5.1.0 bash: line 1: /nonexistent: No such file or directory
# dash dash: 1: cannot open /nonexistent: No such file
#
STD_SED_CMDS.shell+= -e 's,^${.SHELL},${.SHELL:T},'
STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: line [0-9][0-9]*: ,,'
STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: [0-9][0-9]*: ,,'
STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: ,,'
STD_SED_CMDS.shell+= -e 's,: command not found,: not found,'
# The actual error messages for a failed regcomp or regexec differ between the
# implementations.

View File

@ -3,4 +3,5 @@ space after @
echo 'echoed'
echoed
3
whitespace in leading part
exit status 0

View File

@ -1,4 +1,4 @@
# $NetBSD: sh-leading-at.mk,v 1.5 2020/11/15 20:20:58 rillig Exp $
# $NetBSD: sh-leading-at.mk,v 1.6 2023/01/19 19:55:27 rillig Exp $
#
# Tests for shell commands preceded by an '@', to suppress printing
# the command to stdout.
@ -16,3 +16,7 @@ all:
# The leading '@' can be repeated.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@echo '3'
# Since 2023-01-17, the leading '@', '+' and '-' may contain
# whitespace, for compatibility with GNU make.
@ @ @ echo 'whitespace in leading part'

View File

@ -1 +1,11 @@
true
false
*** Error code 1 (ignored)
unknown-command 'needed for needshell in compat.c'
unknown-command: not found
*** Error code 127 (ignored)
unknown-long-option 'needed for needshell in compat.c'
unknown-long-option: not found
whitespace in leading part
*** Error code 127 (ignored)
exit status 0

View File

@ -1,4 +1,4 @@
# $NetBSD: sh-leading-hyphen.mk,v 1.3 2020/11/15 20:20:58 rillig Exp $
# $NetBSD: sh-leading-hyphen.mk,v 1.4 2023/01/19 19:55:27 rillig Exp $
#
# Tests for shell commands preceded by a '-', to ignore the exit status of
# the command line.
@ -11,4 +11,19 @@
# TODO: Implementation
all:
@:;
-true
-false
# An undefined variable expands to an empty string, without warning.
# This is used in practice for prefixing tool names or for DESTDIR.
# The '-' before 'unknown' is interpreted by make as '.IGNORE' flag.
${UNDEF}-unknown-command 'needed for needshell in compat.c'
# Expanding undefined variables may lead to strange error messages
# when the shell interprets single-character options as commands
# instead.
${UNDEF} --unknown-long-option 'needed for needshell in compat.c'
# Since 2023-01-17, the leading '@', '+' and '-' may contain
# whitespace, for compatibility with GNU make.
- - - @echo 'whitespace in leading part'

View File

@ -1,4 +1,6 @@
echo 'this command is not run'
echo 'this command is run'
this command is run
echo 'whitespace in leading part'
whitespace in leading part
exit status 0

View File

@ -1,4 +1,4 @@
# $NetBSD: sh-leading-plus.mk,v 1.4 2020/11/09 20:50:56 rillig Exp $
# $NetBSD: sh-leading-plus.mk,v 1.5 2023/01/19 19:55:27 rillig Exp $
#
# Tests for shell commands preceded by a '+', to run them even if
# the command line option -n is given.
@ -8,3 +8,7 @@
all:
@echo 'this command is not run'
@+echo 'this command is run'
# Since 2023-01-17, the leading '@', '+' and '-' may contain
# whitespace, for compatibility with GNU make.
+ + + @echo 'whitespace in leading part'