xref: /freebsd/contrib/bmake/unit-tests/directive.mk (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
1# $NetBSD: directive.mk,v 1.8 2023/08/19 11:09:02 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# expect+1: Unknown directive ""
19.${:Uinfo} directives cannot be indirect
20
21# There is no directive called '.target', therefore this is parsed as a
22# dependency declaration with 2 targets and 1 source.
23.target target: source
24
25# The following lines demonstrate how the parser tells an .info message apart
26# from a variable assignment to ".info", which syntactically is very similar.
27.MAKEFLAGS: -dv
28.info:=		value		# This is a variable assignment.
29.info?=		value		# This is a variable assignment as well.
30# expect+1: :=	value
31.info :=	value		# The space after the '.info' makes this
32				# a directive.
33.MAKEFLAGS: -d0
34
35# This is a dependency since directives must be given directly.
36# Not even the space after the '.info' can change anything about this.
37.${:Uinfo} : source
38
39# expect+1: Invalid line 'target-without-colon'
40target-without-colon
41
42# expect+1: Invalid line 'target-without-colon another-target'
43target-without-colon another-target
44