xref: /freebsd/contrib/bmake/unit-tests/directive.mk (revision d5e0a182cf153f8993a633b93d9220c99a89e760)
1*d5e0a182SSimon J. Gerraty# $NetBSD: directive.mk,v 1.9 2023/11/19 22:32:44 rillig Exp $
22c3632d1SSimon J. Gerraty#
32c3632d1SSimon J. Gerraty# Tests for the preprocessing directives, such as .if or .info.
42c3632d1SSimon J. Gerraty
52c3632d1SSimon J. Gerraty# TODO: Implementation
62c3632d1SSimon J. Gerraty
7e2eeea75SSimon J. Gerraty# Unknown directives are correctly named in the error messages,
8e2eeea75SSimon J. Gerraty# even if they are indented.
99f45a3c8SSimon J. Gerraty# expect+1: Unknown directive "indented"
10e2eeea75SSimon J. Gerraty.indented none
119f45a3c8SSimon J. Gerraty# expect+1: Unknown directive "indented"
12e2eeea75SSimon J. Gerraty.  indented 2 spaces
139f45a3c8SSimon J. Gerraty# expect+1: Unknown directive "indented"
14e2eeea75SSimon J. Gerraty.	indented tab
15e2eeea75SSimon J. Gerraty
16*d5e0a182SSimon J. Gerraty# Directives must be written directly, not indirectly via
17e2eeea75SSimon J. Gerraty# expressions.
1898875883SSimon J. Gerraty# expect+1: Unknown directive ""
19e2eeea75SSimon J. Gerraty.${:Uinfo} directives cannot be indirect
20e2eeea75SSimon J. Gerraty
21e2eeea75SSimon J. Gerraty# There is no directive called '.target', therefore this is parsed as a
22e2eeea75SSimon J. Gerraty# dependency declaration with 2 targets and 1 source.
23e2eeea75SSimon J. Gerraty.target target: source
24e2eeea75SSimon J. Gerraty
259f45a3c8SSimon J. Gerraty# The following lines demonstrate how the parser tells an .info message apart
269f45a3c8SSimon J. Gerraty# from a variable assignment to ".info", which syntactically is very similar.
27e2eeea75SSimon J. Gerraty.MAKEFLAGS: -dv
289f45a3c8SSimon J. Gerraty.info:=		value		# This is a variable assignment.
29e2eeea75SSimon J. Gerraty.info?=		value		# This is a variable assignment as well.
309f45a3c8SSimon J. Gerraty# expect+1: :=	value
31e2eeea75SSimon J. Gerraty.info :=	value		# The space after the '.info' makes this
32e2eeea75SSimon J. Gerraty				# a directive.
33e2eeea75SSimon J. Gerraty.MAKEFLAGS: -d0
34e2eeea75SSimon J. Gerraty
35e2eeea75SSimon J. Gerraty# This is a dependency since directives must be given directly.
36e2eeea75SSimon J. Gerraty# Not even the space after the '.info' can change anything about this.
37e2eeea75SSimon J. Gerraty.${:Uinfo} : source
38e2eeea75SSimon J. Gerraty
3998875883SSimon J. Gerraty# expect+1: Invalid line 'target-without-colon'
409f45a3c8SSimon J. Gerratytarget-without-colon
419f45a3c8SSimon J. Gerraty
4298875883SSimon J. Gerraty# expect+1: Invalid line 'target-without-colon another-target'
439f45a3c8SSimon J. Gerratytarget-without-colon another-target
44