make/tests/scripts/variables/INCLUDE_DIRS

93 lines
1.9 KiB
Text
Raw Normal View History

# -*-perl-*-
$description = "Test the .INCLUDE_DIRS special variable.";
$details = "";
use Cwd;
$dir = cwd;
$dir =~ s,.*/([^/]+)$,../$1,;
# Test #1: The content of .INCLUDE_DIRS depends on the platform for which
# make was built. What we know for sure is that it shouldn't be
# empty.
#
run_make_test('
ifeq ($(.INCLUDE_DIRS),)
$(warning .INCLUDE_DIRS is empty)
endif
.PHONY: all
all:;@:
',
'', '');
# Test #2: Make sure -I paths end up in .INCLUDE_DIRS.
#
run_make_test('
ifeq ($(dir),)
$(warning dir is empty)
endif
ifeq ($(filter $(dir),$(.INCLUDE_DIRS)),)
[SV 45211] Parse MAKEFLAGS immediately when it's reset When MAKEFLAGS is set in a makefile, reparse it immediately rather than waiting until after all makefiles have been read and parsed. This change doesn't actually fix the SV bug referenced because, even though we do reparse MAKEFLAGS, we don't handle the -r or -R options immediately. Doing this will require more effort. * NEWS: Announce the change. * src/makeint.h: Publish reset_switches() and decode_env_switches() from main.c * src/main.c (main): Don't call construct_include_path(); it will be invoked decode_switches(). Preserve the old values of builtin_rules, builtin_variables, and job_slots before we read makefiles since they can be changed now. (reset_switches): Publish (remove static). Set the initial value of the stringlist list to NULL. (decode_switches): Call construct_include_path() after decoding. (decode_env_switches): Publish (remove static). (define_makeflags): Set the MAKEFLAGS variable for special handling. * src/read.c (eval_makefile): Check for empty include_directories. (construct_include_path): Clear any old value of .INCLUDE_DIRS before appending new values. Free the previous include_directories. * src/variable.c (lookup_special_var): When MAKEFLAGS is set, first reset the switches then re-parse the variable. * tests/run_make_tests.pl: Memo-ize some default variable values. * tests/scripts/options/dash-r: Create tests for setting -r and -R. * tests/scripts/variables/MAKEFLAGS: Test that resetting -I from within the makefile takes effect immediately.
2021-09-05 21:11:44 +00:00
$(warning .INCLUDE_DIRS does not contain $(dir): $(.INCLUDE_DIRS))
endif
.PHONY: all
all:;@:
',
"-I$dir dir=$dir", '');
# Find the default .INCLUDE_DIRS
create_file('defaultdirs.mk', "\$(info \$(.INCLUDE_DIRS))\nall:;\@:\n");
my $cmd = subst_make_string("#MAKEPATH# -f defaultdirs.mk");
my @dirs = `$cmd`;
my $dirs = $dirs[0];
chomp $dirs;
unlink('defaultdirs.mk');
run_make_test("
ifneq (\$(.INCLUDE_DIRS),$dirs)
\$(warning Mismatched \$(.INCLUDE_DIRS) != $dirs)
endif
all:;\@:
",
'', '');
# Verify that -I- disables content from .INCLUDE_DIRS
run_make_test("
ifneq (\$(.INCLUDE_DIRS),)
\$(warning Mismatched \$(.INCLUDE_DIRS) != )
endif
all:;\@:
",
'-I-', '');
# Prefix -I dirs to the front
mkdir('somedir', 0777);
run_make_test("
ifneq (\$(.INCLUDE_DIRS),somedir $dirs)
\$(warning Mismatched \$(.INCLUDE_DIRS) != somedir $dirs)
endif
all:;\@:
",
'-I somedir', '');
# Verify .INCLUDE_DIRS contains files after -I-
run_make_test("
ifneq (\$(.INCLUDE_DIRS),somedir)
\$(warning Mismatched \$(.INCLUDE_DIRS) != somedir)
endif
all:;\@:
",
'-I - -I somedir', '');
rmdir('somedir');
# This tells the test driver that the perl test script executed properly.
1;