tests/make: add placeholders for .PARSEDIR and .INCLUDEDFROMDIR

When run via 'cd usr.bin/make/unit-tests && make test', the tests are in
the current directory.  When run via ATF, the tests are in
/usr/tests/usr.bin/make/unit-tests, while the current directory is a
temporary directory.  Allow both variants, plus others that may occur in
the bmake distribution.
This commit is contained in:
rillig 2022-01-09 20:53:53 +00:00
parent dc0b7d9776
commit 5b01a92554
3 changed files with 13 additions and 10 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.293 2021/12/28 01:04:03 rillig Exp $
# $NetBSD: Makefile,v 1.294 2022/01/09 20:53:53 rillig Exp $
#
# Unit tests for make(1)
#
@ -693,6 +693,9 @@ _SED_CMDS+= -e 's,${TEST_MAKE:T:S,.,\\.,g}[][0-9]* warning,make warning,'
_SED_CMDS+= -e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,'
# replace anything after 'stopped in' with unit-tests
_SED_CMDS+= -e '/stopped/s, /.*, unit-tests,'
# Allow the test files to be placed anywhere.
_SED_CMDS+= -e 's,\(\.PARSEDIR}\) = `'"/[^']*'"',\1 = <some-dir>,'
_SED_CMDS+= -e 's,\(\.INCLUDEDFROMDIR}\) = `'"/[^']*'"',\1 = <some-dir>,'
_SED_CMDS+= -e 's,${TMPDIR},TMPDIR,g'
# canonicalize ${.OBJDIR} and ${.CURDIR}
.if ${.OBJDIR} != ${.CURDIR}

View File

@ -96,11 +96,11 @@ make: "directive-for-escape.mk" line 152: newline in .for value
"
For: loop body:
: ${:U" "}
SetFilenameVars: ${.PARSEDIR} = `<curdir>' ${.PARSEFILE} = `directive-for-escape.mk'
SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `directive-for-escape.mk'
Parsing line 153: : ${:U" "}
ParseDependency(: " ")
ParseEOF: returning to file directive-for-escape.mk, line 155
SetFilenameVars: ${.PARSEDIR} = `<curdir>' ${.PARSEFILE} = `directive-for-escape.mk'
SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `directive-for-escape.mk'
Parsing line 155: .MAKEFLAGS: -d0
ParseDependency(.MAKEFLAGS: -d0)
make: Fatal errors encountered -- cannot continue

View File

@ -1,18 +1,18 @@
Parse_PushInput: .for loop in opt-debug-parse.mk, line 16
SetFilenameVars: ${.PARSEDIR} = `<curdir>' ${.PARSEFILE} = `opt-debug-parse.mk'
SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `opt-debug-parse.mk'
Parsing line 20: .info trace with multi-line .for loop head
make: "opt-debug-parse.mk" line 20: trace with multi-line .for loop head
in .for loop from opt-debug-parse.mk:16 with var = value
ParseEOF: returning to file opt-debug-parse.mk, line 22
SetFilenameVars: ${.PARSEDIR} = `<curdir>' ${.PARSEFILE} = `opt-debug-parse.mk'
SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `opt-debug-parse.mk'
Parsing line 25: .include "/dev/null"
Parse_PushInput: file /dev/null, line 1
SetFilenameVars: ${.PARSEDIR} = `/dev' ${.PARSEFILE} = `null'
SetFilenameVars: ${.INCLUDEDFROMDIR} = `<curdir>' ${.INCLUDEDFROMFILE} = `opt-debug-parse.mk'
SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `null'
SetFilenameVars: ${.INCLUDEDFROMDIR} = <some-dir> ${.INCLUDEDFROMFILE} = `opt-debug-parse.mk'
ParseEOF: returning to file opt-debug-parse.mk, line 26
SetFilenameVars: ${.PARSEDIR} = `<curdir>' ${.PARSEFILE} = `opt-debug-parse.mk'
SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `opt-debug-parse.mk'
Parse_PushInput: .for loop in opt-debug-parse.mk, line 30
SetFilenameVars: ${.PARSEDIR} = `<curdir>' ${.PARSEFILE} = `opt-debug-parse.mk'
SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `opt-debug-parse.mk'
Parsing line 31: .info trace
make: "opt-debug-parse.mk" line 31: trace
in .for loop from opt-debug-parse.mk:30 with a = 1, b = 2, c = 3
@ -20,7 +20,7 @@ Parsing line 31: .info trace
make: "opt-debug-parse.mk" line 31: trace
in .for loop from opt-debug-parse.mk:30 with a = 4, b = 5, c = 6
ParseEOF: returning to file opt-debug-parse.mk, line 33
SetFilenameVars: ${.PARSEDIR} = `<curdir>' ${.PARSEFILE} = `opt-debug-parse.mk'
SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `opt-debug-parse.mk'
Parsing line 35: .MAKEFLAGS: -d0
ParseDependency(.MAKEFLAGS: -d0)
exit status 0