freebsd-src/unit-tests/varmod-mtime.mk
Simon J. Gerraty 945078deae Import bmake-20230510
Relevant/interesting changes:

	o parse.c: don't print null filename in stack traces
	o for.c: skip syntactically wrong .for loops
	o var.c: allow for :gmtime=${mtime}
	add :mtime[=timestamp] where timestamp is used if stat(2)
	fails, if :mtime=error stat(2) failure causes error.
	o make.1: fix documentation of .PREFIX to match reality and POSIX
	o unit-tests: improved var-scope-local
2023-05-13 10:03:50 -07:00

31 lines
725 B
Makefile

# $NetBSD: varmod-mtime.mk,v 1.1 2023/05/09 20:14:27 sjg Exp $
#
# Tests for the :mtime variable modifier, which provides mtime
# of variable value assumed to be a pathname.
all:
# mtime of this makefile
mtime:= ${MAKEFILE:mtime}
# if pathname does not exist and timestamp is provided
# that is the result
.if ${no/such:L:mtime=0} != "0"
. error
.endif
.if ${no/such:L:mtime=42} != "42"
. error
.endif
# if no timestamp is provided and stat(2) fails use current time
.if ${no/such:L:mtime} < ${mtime}
. error no/such:L:mtime ${no/such:L:mtime} < ${mtime}
.endif
COOKIE = ${TMPDIR}/varmod-mtime.cookie
x!= touch ${COOKIE}
.if ${COOKIE:mtime=0} < ${mtime}
. error COOKIE:mtime=0 ${COOKIE:mtime=0} < ${mtime}
.endif