Module Name: src Committed By: rillig Date: Thu Jun 1 07:27:31 UTC 2023
Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make/unit-tests: Makefile check-expect.lua cond-eof.exp cond-eof.mk cond-func-empty.mk cond-token-string.mk dep.mk directive-endif.exp directive-endif.mk directive-for.mk varmod-subst.mk varname-makeflags.mk varparse-dynamic.mk Removed Files: src/usr.bin/make/unit-tests: forsubst.exp forsubst.mk Log Message: tests/make: clean up comments, extend a few tests To generate a diff of this commit: cvs rdiff -u -r1.1265 -r1.1266 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.335 -r1.336 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/check-expect.lua \ src/usr.bin/make/unit-tests/directive-endif.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cond-eof.exp \ src/usr.bin/make/unit-tests/cond-eof.mk \ src/usr.bin/make/unit-tests/dep.mk cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/cond-func-empty.mk cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-token-string.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/directive-endif.mk \ src/usr.bin/make/unit-tests/varparse-dynamic.mk cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/directive-for.mk cvs rdiff -u -r1.1 -r0 src/usr.bin/make/unit-tests/forsubst.exp cvs rdiff -u -r1.3 -r0 src/usr.bin/make/unit-tests/forsubst.mk cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-subst.mk cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varname-makeflags.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1265 src/distrib/sets/lists/tests/mi:1.1266 --- src/distrib/sets/lists/tests/mi:1.1265 Wed May 31 00:18:44 2023 +++ src/distrib/sets/lists/tests/mi Thu Jun 1 07:27:30 2023 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1265 2023/05/31 00:18:44 riastradh Exp $ +# $NetBSD: mi,v 1.1266 2023/06/01 07:27:30 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5821,8 +5821,8 @@ ./usr/tests/usr.bin/make/unit-tests/export.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/forloop.exp tests-obsolete obsolete,atf ./usr/tests/usr.bin/make/unit-tests/forloop.mk tests-obsolete obsolete,atf -./usr/tests/usr.bin/make/unit-tests/forsubst.exp tests-usr.bin-tests compattestfile,atf -./usr/tests/usr.bin/make/unit-tests/forsubst.mk tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/forsubst.exp tests-obsolete obsolete,atf +./usr/tests/usr.bin/make/unit-tests/forsubst.mk tests-obsolete obsolete,atf ./usr/tests/usr.bin/make/unit-tests/gnode-submake.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/gnode-submake.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/hanoi-include.exp tests-usr.bin-tests compattestfile,atf Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.335 src/usr.bin/make/unit-tests/Makefile:1.336 --- src/usr.bin/make/unit-tests/Makefile:1.335 Wed May 10 13:03:06 2023 +++ src/usr.bin/make/unit-tests/Makefile Thu Jun 1 07:27:30 2023 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.335 2023/05/10 13:03:06 rillig Exp $ +# $NetBSD: Makefile,v 1.336 2023/06/01 07:27:30 rillig Exp $ # # Unit tests for make(1) # @@ -212,7 +212,6 @@ TESTS+= export TESTS+= export-all TESTS+= export-env TESTS+= export-variants -TESTS+= forsubst TESTS+= gnode-submake TESTS+= hanoi-include TESTS+= impsrc Index: src/usr.bin/make/unit-tests/check-expect.lua diff -u src/usr.bin/make/unit-tests/check-expect.lua:1.4 src/usr.bin/make/unit-tests/check-expect.lua:1.5 --- src/usr.bin/make/unit-tests/check-expect.lua:1.4 Tue May 9 19:43:12 2023 +++ src/usr.bin/make/unit-tests/check-expect.lua Thu Jun 1 07:27:30 2023 @@ -1,5 +1,5 @@ #! /usr/bin/lua --- $NetBSD: check-expect.lua,v 1.4 2023/05/09 19:43:12 rillig Exp $ +-- $NetBSD: check-expect.lua,v 1.5 2023/06/01 07:27:30 rillig Exp $ --[[ @@ -58,7 +58,7 @@ local function collect_lineno_diagnostic for _, line in ipairs(exp_lines) do ---@type string | nil, string, string local l_fname, l_lineno, l_msg = - line:match("^make: \"([^\"]+)\" line (%d+): (.*)") + line:match('^make: "([^"]+)" line (%d+): (.*)') if l_fname ~= nil then local location = ("%s:%d"):format(l_fname, l_lineno) if by_location[location] == nil then Index: src/usr.bin/make/unit-tests/directive-endif.exp diff -u src/usr.bin/make/unit-tests/directive-endif.exp:1.4 src/usr.bin/make/unit-tests/directive-endif.exp:1.5 --- src/usr.bin/make/unit-tests/directive-endif.exp:1.4 Thu Dec 9 20:13:10 2021 +++ src/usr.bin/make/unit-tests/directive-endif.exp Thu Jun 1 07:27:30 2023 @@ -1,8 +1,8 @@ make: "directive-endif.mk" line 18: The .endif directive does not take arguments make: "directive-endif.mk" line 23: The .endif directive does not take arguments -make: "directive-endif.mk" line 33: The .endif directive does not take arguments -make: "directive-endif.mk" line 39: The .endif directive does not take arguments -make: "directive-endif.mk" line 45: Unknown directive "endifx" +make: "directive-endif.mk" line 34: The .endif directive does not take arguments +make: "directive-endif.mk" line 41: The .endif directive does not take arguments +make: "directive-endif.mk" line 46: Unknown directive "endifx" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/cond-eof.exp diff -u src/usr.bin/make/unit-tests/cond-eof.exp:1.3 src/usr.bin/make/unit-tests/cond-eof.exp:1.4 --- src/usr.bin/make/unit-tests/cond-eof.exp:1.3 Fri Dec 10 23:12:44 2021 +++ src/usr.bin/make/unit-tests/cond-eof.exp Thu Jun 1 07:27:30 2023 @@ -1,6 +1,6 @@ -make: "cond-eof.mk" line 15: Malformed conditional (0 ${SIDE_EFFECT} ${SIDE_EFFECT2}) -make: "cond-eof.mk" line 17: Malformed conditional (1 ${SIDE_EFFECT} ${SIDE_EFFECT2}) -make: "cond-eof.mk" line 19: Malformed conditional ((0) ${SIDE_EFFECT} ${SIDE_EFFECT2}) +make: "cond-eof.mk" line 19: Malformed conditional (0 ${SIDE_EFFECT} ${SIDE_EFFECT2}) +make: "cond-eof.mk" line 22: Malformed conditional (1 ${SIDE_EFFECT} ${SIDE_EFFECT2}) +make: "cond-eof.mk" line 25: Malformed conditional ((0) ${SIDE_EFFECT} ${SIDE_EFFECT2}) make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/cond-eof.mk diff -u src/usr.bin/make/unit-tests/cond-eof.mk:1.3 src/usr.bin/make/unit-tests/cond-eof.mk:1.4 --- src/usr.bin/make/unit-tests/cond-eof.mk:1.3 Fri Dec 10 23:12:44 2021 +++ src/usr.bin/make/unit-tests/cond-eof.mk Thu Jun 1 07:27:30 2023 @@ -1,7 +1,10 @@ -# $NetBSD: cond-eof.mk,v 1.3 2021/12/10 23:12:44 rillig Exp $ +# $NetBSD: cond-eof.mk,v 1.4 2023/06/01 07:27:30 rillig Exp $ # -# Tests for parsing conditions, especially the end of such conditions, which -# are represented as the token TOK_EOF. +# Tests for parsing the end of '.if' conditions, which are represented as the +# token TOK_EOF. + +# expect-all + SIDE_EFFECT= ${:!echo 'side effect' 1>&2!} SIDE_EFFECT2= ${:!echo 'side effect 2' 1>&2!} @@ -12,9 +15,12 @@ SIDE_EFFECT2= ${:!echo 'side effect 2' 1 # These syntax errors are an edge case that does not occur during normal # operation. Still, it is easy to avoid evaluating these expressions, just in # case they have side effects. +# expect+1: Malformed conditional (0 ${SIDE_EFFECT} ${SIDE_EFFECT2}) .if 0 ${SIDE_EFFECT} ${SIDE_EFFECT2} .endif +# expect+1: Malformed conditional (1 ${SIDE_EFFECT} ${SIDE_EFFECT2}) .if 1 ${SIDE_EFFECT} ${SIDE_EFFECT2} .endif +# expect+1: Malformed conditional ((0) ${SIDE_EFFECT} ${SIDE_EFFECT2}) .if (0) ${SIDE_EFFECT} ${SIDE_EFFECT2} .endif Index: src/usr.bin/make/unit-tests/dep.mk diff -u src/usr.bin/make/unit-tests/dep.mk:1.3 src/usr.bin/make/unit-tests/dep.mk:1.4 --- src/usr.bin/make/unit-tests/dep.mk:1.3 Mon Dec 13 23:38:54 2021 +++ src/usr.bin/make/unit-tests/dep.mk Thu Jun 1 07:27:30 2023 @@ -1,4 +1,4 @@ -# $NetBSD: dep.mk,v 1.3 2021/12/13 23:38:54 rillig Exp $ +# $NetBSD: dep.mk,v 1.4 2023/06/01 07:27:30 rillig Exp $ # # Tests for dependency declarations, such as "target: sources". @@ -15,4 +15,16 @@ only-colon:: # would be another error message. only-colon: + +# Before parse.c 1.158 from 2009-10-07, the parser broke dependency lines at +# the first ';', without parsing expressions as such. It interpreted the +# first ';' as the separator between the dependency and its commands, and the +# '^' as a shell command. +all: for-subst +.for file in ${.PARSEFILE} +for-subst: ${file:S;^;./;g} + @echo ".for with :S;... OK" +.endfor + + all: Index: src/usr.bin/make/unit-tests/cond-func-empty.mk diff -u src/usr.bin/make/unit-tests/cond-func-empty.mk:1.18 src/usr.bin/make/unit-tests/cond-func-empty.mk:1.19 --- src/usr.bin/make/unit-tests/cond-func-empty.mk:1.18 Sat Mar 4 21:15:30 2023 +++ src/usr.bin/make/unit-tests/cond-func-empty.mk Thu Jun 1 07:27:30 2023 @@ -1,4 +1,4 @@ -# $NetBSD: cond-func-empty.mk,v 1.18 2023/03/04 21:15:30 rillig Exp $ +# $NetBSD: cond-func-empty.mk,v 1.19 2023/06/01 07:27:30 rillig Exp $ # # Tests for the empty() function in .if conditions, which tests a variable # expression for emptiness. @@ -25,7 +25,7 @@ WORD= word .endif # The :S modifier replaces the empty value with an actual word. After -# applying the :S modifier to the expression, it value is 'empty', so it is +# applying the :S modifier to the expression, its value is 'empty', so it is # no longer empty, but it is still based on an undefined variable. There are # a few modifiers that turn an undefined expression into a defined expression, # among them :U and :D, but not :S. Therefore, at the end of evaluating the Index: src/usr.bin/make/unit-tests/cond-token-string.mk diff -u src/usr.bin/make/unit-tests/cond-token-string.mk:1.6 src/usr.bin/make/unit-tests/cond-token-string.mk:1.7 --- src/usr.bin/make/unit-tests/cond-token-string.mk:1.6 Sun May 8 06:57:00 2022 +++ src/usr.bin/make/unit-tests/cond-token-string.mk Thu Jun 1 07:27:30 2023 @@ -1,4 +1,4 @@ -# $NetBSD: cond-token-string.mk,v 1.6 2022/05/08 06:57:00 rillig Exp $ +# $NetBSD: cond-token-string.mk,v 1.7 2023/06/01 07:27:30 rillig Exp $ # # Tests for quoted string literals in .if conditions. # @@ -9,7 +9,7 @@ # TODO: Implementation # Cover the code in CondParser_String that frees the memory after parsing -# a variable expression based on an undefined variable. +# an expression based on an undefined variable. .if "" != "${:Uvalue:Z}" . error .else Index: src/usr.bin/make/unit-tests/directive-endif.mk diff -u src/usr.bin/make/unit-tests/directive-endif.mk:1.5 src/usr.bin/make/unit-tests/directive-endif.mk:1.6 --- src/usr.bin/make/unit-tests/directive-endif.mk:1.5 Mon Dec 14 21:56:17 2020 +++ src/usr.bin/make/unit-tests/directive-endif.mk Thu Jun 1 07:27:30 2023 @@ -1,4 +1,4 @@ -# $NetBSD: directive-endif.mk,v 1.5 2020/12/14 21:56:17 rillig Exp $ +# $NetBSD: directive-endif.mk,v 1.6 2023/06/01 07:27:30 rillig Exp $ # # Tests for the .endif directive. # @@ -8,18 +8,18 @@ # See also: # Cond_EvalLine -# TODO: Implementation +# expect-all .MAKEFLAGS: -dL -# Error: .endif does not take arguments .if 0 -# Since 2020-12-15, complain about the extra text after the 'endif'. +# Since 2020-12-15: +# expect+1: The .endif directive does not take arguments .endif 0 -# Error: .endif does not take arguments .if 1 -# Since 2020-12-15, complain about the extra text after the 'endif'. +# Since 2020-12-15: +# expect+1: The .endif directive does not take arguments .endif 1 # Comments are allowed after an '.endif'. @@ -29,21 +29,19 @@ # Only whitespace and comments are allowed after an '.endif', but nothing # else. .if 1 -# Since 2020-12-15, complain about the extra text after the 'endif'. +# Since 2020-12-15: +# expect+1: The .endif directive does not take arguments .endif0 # Only whitespace and comments are allowed after an '.endif', but nothing # else. .if 1 -# Since 2020-12-15, complain about the extra text after the 'endif'. +# Since 2020-12-15: +# expect+1: The .endif directive does not take arguments .endif/ -# After an '.endif', no other letter must occur. This 'endifx' is not -# parsed as an 'endif', therefore another '.endif' must follow to balance -# the directives. +# After an '.endif', no other letter must occur. .if 1 +# expect+1: Unknown directive "endifx" .endifx -.endif # to close the preceding '.if' - -all: - @:; +.endif # to close the preceding '.if' Index: src/usr.bin/make/unit-tests/varparse-dynamic.mk diff -u src/usr.bin/make/unit-tests/varparse-dynamic.mk:1.5 src/usr.bin/make/unit-tests/varparse-dynamic.mk:1.6 --- src/usr.bin/make/unit-tests/varparse-dynamic.mk:1.5 Mon Feb 22 20:38:55 2021 +++ src/usr.bin/make/unit-tests/varparse-dynamic.mk Thu Jun 1 07:27:30 2023 @@ -1,8 +1,8 @@ -# $NetBSD: varparse-dynamic.mk,v 1.5 2021/02/22 20:38:55 rillig Exp $ +# $NetBSD: varparse-dynamic.mk,v 1.6 2023/06/01 07:27:30 rillig Exp $ # Before 2020-07-27, there was an off-by-one error in Var_Parse that skipped # the last character in the variable name. -# To trigger the bug, the variable must not be defined. +# To trigger the bug, the variable had to be undefined. .if ${.TARGET} # exact match, may be undefined .endif .if ${.TARGEX} # 1 character difference, must be defined Index: src/usr.bin/make/unit-tests/directive-for.mk diff -u src/usr.bin/make/unit-tests/directive-for.mk:1.20 src/usr.bin/make/unit-tests/directive-for.mk:1.21 --- src/usr.bin/make/unit-tests/directive-for.mk:1.20 Wed May 10 13:03:06 2023 +++ src/usr.bin/make/unit-tests/directive-for.mk Thu Jun 1 07:27:30 2023 @@ -1,4 +1,4 @@ -# $NetBSD: directive-for.mk,v 1.20 2023/05/10 13:03:06 rillig Exp $ +# $NetBSD: directive-for.mk,v 1.21 2023/06/01 07:27:30 rillig Exp $ # # Tests for the .for directive. # @@ -87,9 +87,9 @@ var2= value before . warning After the .for loop, var2 must still have its original value. .endif -# Until 2008-12-21, the values of the iteration variables were simply -# inserted as plain text and then parsed as usual, which made it possible -# to achieve all kinds of strange effects, such as generating '.if' +# Before for.c 1.39 from 2008-12-21, the values of the iteration variables +# were simply inserted as plain text and then parsed as usual, which made it +# possible to achieve all kinds of strange effects, such as generating '.if' # directives or inserting '$' characters in random places, thereby changing # how following '$' are interpreted. # Index: src/usr.bin/make/unit-tests/varmod-subst.mk diff -u src/usr.bin/make/unit-tests/varmod-subst.mk:1.9 src/usr.bin/make/unit-tests/varmod-subst.mk:1.10 --- src/usr.bin/make/unit-tests/varmod-subst.mk:1.9 Mon Sep 6 21:18:55 2021 +++ src/usr.bin/make/unit-tests/varmod-subst.mk Thu Jun 1 07:27:30 2023 @@ -1,7 +1,9 @@ -# $NetBSD: varmod-subst.mk,v 1.9 2021/09/06 21:18:55 rillig Exp $ +# $NetBSD: varmod-subst.mk,v 1.10 2023/06/01 07:27:30 rillig Exp $ # # Tests for the :S,from,to, variable modifier. +# expect-all + all: mod-subst all: mod-subst-delimiter all: mod-subst-chain @@ -99,6 +101,14 @@ WORDS= sequences of letters . error .endif + +# When a word is replaced with nothing, the remaining words are separated by a +# single space, not two. +.if ${1 2 3:L:S,2,,} != "1 3" +. error +.endif + + mod-subst: @echo $@: @echo :${:Ua b b c:S,a b,,:Q}: Index: src/usr.bin/make/unit-tests/varname-makeflags.mk diff -u src/usr.bin/make/unit-tests/varname-makeflags.mk:1.7 src/usr.bin/make/unit-tests/varname-makeflags.mk:1.8 --- src/usr.bin/make/unit-tests/varname-makeflags.mk:1.7 Sat Feb 25 19:24:07 2023 +++ src/usr.bin/make/unit-tests/varname-makeflags.mk Thu Jun 1 07:27:30 2023 @@ -1,4 +1,4 @@ -# $NetBSD: varname-makeflags.mk,v 1.7 2023/02/25 19:24:07 rillig Exp $ +# $NetBSD: varname-makeflags.mk,v 1.8 2023/06/01 07:27:30 rillig Exp $ # # Tests for the environment variable 'MAKEFLAGS', from which additional # command line arguments are read before the actual command line arguments. @@ -96,7 +96,7 @@ dollars_stage_1: # $\ the value of the variable named '\' # {varname\} a literal string # - # Since the variable name '\' is not defined, the resulting value is + # Since the variable named '\' is not defined, the resulting value is # '\{varname\}'. Make doesn't handle isolated '$' characters in # strings well, instead each '$' has to be part of a '$$' or be part # of a subexpression like '${VAR}'. @@ -135,9 +135,9 @@ dollars_stage_3: @echo '$@: MAKEFLAGS=<'${MAKEFLAGS:Q}'>' -# Demonstrates in which exact order the MAKEFLAGS are built together from the -# parent MAKEFLAGS and the flags from the command line, in particular that -# variable assignments are passed at the end, after the options. +# Demonstrates in which exact order the MAKEFLAGS are built from the parent +# MAKEFLAGS and the flags from the command line, in particular that variable +# assignments are passed at the end, after the options. append_stage_0: @echo '$@: MAKEFLAGS=<'${MAKEFLAGS:Q}'>' @${MAKE} -Dbefore-0 -f ${MAKEFILE} append_stage_1 VAR0=value -Dafter-0