xref: /freebsd/contrib/bmake/unit-tests/opt-chdir.mk (revision b64c5a0ace59af62eff52bfe110a521dc73c937b)
1# $NetBSD: opt-chdir.mk,v 1.7 2024/04/02 11:11:00 rillig Exp $
2#
3# Tests for the -C command line option, which changes the directory at the
4# beginning.
5#
6# This option has been available since 2009-08-27.
7
8.MAKEFLAGS: -d0			# switch stdout to line-buffered
9
10all: chdir-root
11all: chdir-nonexistent
12
13# Changing to another directory is possible via the command line.
14# In this test, it is the root directory since almost any other directory
15# is not guaranteed to exist on every platform.
16chdir-root: .PHONY .IGNORE
17	@MAKE_OBJDIR_CHECK_WRITABLE=no ${MAKE} -C / -V 'cwd: $${.CURDIR}'
18
19# Trying to change to a nonexistent directory exits immediately.
20# Note: just because the whole point of /nonexistent is that it should
21# not exist - doesn't mean it doesn't.
22chdir-nonexistent: .PHONY .IGNORE
23	@${MAKE} -C /nonexistent.${.MAKE.PID}
24