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