diff options
author | Paul Smith <psmith@gnu.org> | 2022-12-24 09:26:24 -0500 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2022-12-24 10:52:43 -0500 |
commit | 76d2e5d98dbbf655f74f6ef2f6dd3cdd45052ea0 (patch) | |
tree | 3a9ed561d856a8031812f472cae408f9bc74fe8d /tests | |
parent | a581146562009407649b85fac48f4e7cafe5eaa0 (diff) | |
download | make-git-76d2e5d98dbbf655f74f6ef2f6dd3cdd45052ea0.tar.gz |
[SV 63552] Change directories before constructing include paths
* src/makeint.h (reset_makeflags): New function to handle changing
MAKEFLAGS from within makefiles. Remove decode_env_switches().
* src/variable.c (set_special_var): Call reset_makeflags() instead
of various internal methods.
* src/main.c (decode_env_switches): Only internal now so make static.
(decode_switches): Don't invoke construct_include_path() yet.
(reset_makeflags): Decode env switches and construct include paths.
(main): Construct include paths after we process -C options.
* tests/scripts/options/dash-C: Rewrite to use new test constructs.
Add a test using both -C and -I together.
Add a test for multiple -C options.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/scripts/options/dash-C | 76 |
1 files changed, 31 insertions, 45 deletions
diff --git a/tests/scripts/options/dash-C b/tests/scripts/options/dash-C index 7daf69f2..e25923d8 100644 --- a/tests/scripts/options/dash-C +++ b/tests/scripts/options/dash-C @@ -2,65 +2,51 @@ $description = "Test the -C option to GNU make."; -$details = "\ -This test is similar to the clean test except that this test creates the file -to delete in the work directory instead of the current directory. Make is -called from another directory using the -C workdir option so that it can both -find the makefile and the file to delete in the work directory."; +use File::Spec; -$example = $workdir . $pathsep . "EXAMPLE"; +# Pre-set $makefile to be in a subdirectory +$makefile = 'Makefile'; -open(MAKEFILE,"> $makefile"); -print MAKEFILE qq! -all: ; \@echo This makefile did not clean the dir ... good -clean: ; $CMD_rmfile EXAMPLE\$(ext) -!; -close(MAKEFILE); +my $_srcdir = 'src'; +mkdir($_srcdir, 0775); -# TEST #1 -# ------- -touch($example); - -run_make_with_options("${testname}.mk", "-C $workdir clean", &get_logfile); - -use Cwd; - -chdir $workdir; -$wpath = cwd(); -chdir $cwdpath; - -if (-f $example) { - $test_passed = 0; -} +my $_incdir = 'inc'; +mkdir($_incdir, 0775); -# Create the answer to what should be produced by this Makefile -$answer = "$make_name: Entering directory '$wpath'\n" - . "$CMD_rmfile EXAMPLE\n" - . "$make_name: Leaving directory '$wpath'\n"; - -compare_output($answer,&get_logfile(1)); +my $_mkpath = File::Spec->catfile($_srcdir, $makefile); +create_file($_mkpath, "include \$(file)\nall: ;\n"); +# TEST #1 +# ------- +run_make_test('', "-C $_srcdir --no-print-directory", + "#MAKE#: 'all' is up to date."); # TEST #2 # ------- # Do it again with trailing "/"; this should work the same -$example .= "slash"; +run_make_test(undef, "-C $_srcdir/ --no-print-directory", + "#MAKE#: 'all' is up to date."); + +# Test stringing together multiple -C options + +run_make_test(undef, "-C $_incdir -C .. -C $_srcdir --no-print-directory", + "#MAKE#: 'all' is up to date."); -touch($example); +# SV 63552 - Ensure -I is considered after -C -run_make_with_options("${testname}.mk", "-C $workdir/ clean ext=slash", &get_logfile); +my $_incfile = 'test'; +my $_incpath = File::Spec->catfile($_incdir, $_incfile); +create_file($_incpath, '$(info included)'); -if (-f $example) { - $test_passed = 0; -} +my $_incopt = File::Spec->catfile('..', $_incdir); -# Create the answer to what should be produced by this Makefile -$answer = "$make_name: Entering directory '$wpath'\n" - . "$CMD_rmfile EXAMPLEslash\n" - . "$make_name: Leaving directory '$wpath'\n"; +run_make_test(undef, "-C src -I $_incopt --no-print-directory file=$_incfile", + "included\n#MAKE#: 'all' is up to date."); -&compare_output($answer,&get_logfile(1)); +unlink($_incpath); +rmdir($_incdir); -unlink($example); +unlink($_mkpath); +rmdir($_srcdir); 1; |