xref: /freebsd/contrib/bmake/unit-tests/directive.mk (revision 5956d97f4b3204318ceb6aa9c77bd0bc6ea87a41)
1# $NetBSD: directive.mk,v 1.6 2022/01/23 16:09:38 rillig Exp $
2#
3# Tests for the preprocessing directives, such as .if or .info.
4
5# TODO: Implementation
6
7# Unknown directives are correctly named in the error messages,
8# even if they are indented.
9# expect+1: Unknown directive "indented"
10.indented none
11# expect+1: Unknown directive "indented"
12.  indented 2 spaces
13# expect+1: Unknown directive "indented"
14.	indented tab
15
16# Directives must be written directly, not indirectly via variable
17# expressions.
18# FIXME: The error message is misleading because it shows the expanded text of
19#  the line, while the parser works on the unexpanded line.
20# expect+1: Unknown directive "info"
21.${:Uinfo} directives cannot be indirect
22
23# There is no directive called '.target', therefore this is parsed as a
24# dependency declaration with 2 targets and 1 source.
25.target target: source
26
27# The following lines demonstrate how the parser tells an .info message apart
28# from a variable assignment to ".info", which syntactically is very similar.
29.MAKEFLAGS: -dv
30.info:=		value		# This is a variable assignment.
31.info?=		value		# This is a variable assignment as well.
32# expect+1: :=	value
33.info :=	value		# The space after the '.info' makes this
34				# a directive.
35.MAKEFLAGS: -d0
36
37# This is a dependency since directives must be given directly.
38# Not even the space after the '.info' can change anything about this.
39.${:Uinfo} : source
40
41# expect+1: Invalid line type
42target-without-colon
43
44# expect+1: Invalid line type
45target-without-colon another-target
46