xref: /freebsd/contrib/bmake/unit-tests/cond-func-commands.mk (revision 6a7405f5a6b639682cacf01e35d561411ff556aa)
1# $NetBSD: cond-func-commands.mk,v 1.6 2025/01/10 23:00:38 rillig Exp $
2#
3# Tests for the commands() function in .if conditions.
4
5.MAIN: all
6
7# At this point, the target 'target' does not exist yet, therefore it cannot
8# have commands.  Sounds obvious, but good to know that it is really so.
9.if commands(target)
10.  error
11.endif
12
13target:
14
15# Now the target exists, but it still has no commands.
16.if commands(target)
17.  error
18.endif
19
20target:
21	# not a command
22
23# Even after the comment, the target still has no commands.
24.if commands(target)
25.  error
26.endif
27
28target:
29	@:;
30
31# Finally the target has commands.
32.if !commands(target)
33.  error
34.endif
35
36# Expressions in the argument of a function call don't have to be defined.
37.if commands(${UNDEF})
38.  error
39.endif
40
41all:
42	@:;
43