xref: /freebsd/contrib/bmake/unit-tests/directive-include-fatal.mk (revision 6a7405f5a6b639682cacf01e35d561411ff556aa)
1*6a7405f5SSimon J. Gerraty# $NetBSD: directive-include-fatal.mk,v 1.6 2025/01/11 21:21:33 rillig Exp $
2956e45f6SSimon J. Gerraty#
3956e45f6SSimon J. Gerraty# Test for the .include directive combined with fatal errors.
4956e45f6SSimon J. Gerraty#
5956e45f6SSimon J. Gerraty# At 2020-09-13, the code in Parse_File that sets "fatals = 0" looked
6956e45f6SSimon J. Gerraty# suspicious, as if it were possible to suppress fatal errors by including
7956e45f6SSimon J. Gerraty# another file.  It was a false alarm though, since Parse_File only handles
8956e45f6SSimon J. Gerraty# the top-level makefiles from the command line.  Any included files are
9dba7b0efSSimon J. Gerraty# handled by IncludeFile instead, and that function does not reset
10956e45f6SSimon J. Gerraty# the "fatals" counter.
11956e45f6SSimon J. Gerraty
12956e45f6SSimon J. Gerraty# Using an undefined variable in a condition generates a fatal error.
13*6a7405f5SSimon J. Gerraty# expect+1: Variable "UNDEF" is undefined
14956e45f6SSimon J. Gerraty.if ${UNDEF}
15956e45f6SSimon J. Gerraty.endif
16956e45f6SSimon J. Gerraty
17956e45f6SSimon J. Gerraty# Including another file does not reset the global variable "fatals".
18956e45f6SSimon J. Gerraty# The exit status will be 1.
19956e45f6SSimon J. Gerraty.include "/dev/null"
20956e45f6SSimon J. Gerraty
21956e45f6SSimon J. Gerraty# Adding another file to be included has no effect either.
22956e45f6SSimon J. Gerraty# When the command line is parsed, the additional file is only enqueued
23956e45f6SSimon J. Gerraty# in the global "makefiles" variable, but not immediately run through
24956e45f6SSimon J. Gerraty# Parse_File.
25956e45f6SSimon J. Gerraty.MAKEFLAGS: -f "/dev/null"
26956e45f6SSimon J. Gerraty
27956e45f6SSimon J. Gerratyall:
28956e45f6SSimon J. Gerraty	@:;
29