mirror of
https://git.savannah.gnu.org/git/make.git
synced 2024-12-28 15:57:48 +00:00
414af96a50
Go through both run_make_tests.pl and test_driver.pl and slightly modernize the Perl and clean up indentation etc. Fix a number of warnings in the test scripts detected by running with -w. * tests/test_driver.pl: Move make error string detection out of the base test driver. (run_all_tests): Ensure that we always look for tests in the cwd. * tests/run_make_tests.pl: Use File::Spec for path manipulations. Correctly use setlocale() when detecting error strings. Get configuration from the config-flags.pm file not config.status. * tests/scripts/features/archives: Use new $cwddir variable. * tests/scripts/features/reinvoke: Add missing semicolon. * tests/scripts/features/vpath2: Avoid non-existent variable. * tests/scripts/functions/foreach: Escape variables. * tests/scripts/misc/bs-nl: Remove non-existing \v escape sequence. * tests/scripts/misc/general4: Use handy create_file(). * tests/scripts/options/dash-C: Use Cwd/$cwddir. * tests/scripts/options/dash-I: Use subst_make_string() and #PWD#. * tests/scripts/options/symlinks: Use File::Spec. * tests/scripts/targets/DEFAULT: Use create_file and run_make_test. * tests/scripts/variables/CURDIR: Use run_make_test. * tests/scripts/variables/automatic: Remove extraneous "\". * tests/scripts/vms/library: Remove extra "my" and extraneous "\".
122 lines
3 KiB
Perl
122 lines
3 KiB
Perl
# -*-perl-*-
|
|
|
|
$description = "Test automatic variable setting.";
|
|
|
|
$details = "";
|
|
|
|
use Cwd;
|
|
|
|
$dir = cwd;
|
|
$dir =~ s,.*/([^/]+)$,../$1,;
|
|
|
|
open(MAKEFILE, "> $makefile");
|
|
print MAKEFILE "dir = $dir\n";
|
|
print MAKEFILE <<'EOF';
|
|
.SUFFIXES:
|
|
.SUFFIXES: .x .y .z
|
|
$(dir)/foo.x : baz.z $(dir)/bar.y baz.z
|
|
@echo '$$@ = $@, $$(@D) = $(@D), $$(@F) = $(@F)'
|
|
@echo '$$* = $*, $$(*D) = $(*D), $$(*F) = $(*F)'
|
|
@echo '$$< = $<, $$(<D) = $(<D), $$(<F) = $(<F)'
|
|
@echo '$$^ = $^, $$(^D) = $(^D), $$(^F) = $(^F)'
|
|
@echo '$$+ = $+, $$(+D) = $(+D), $$(+F) = $(+F)'
|
|
@echo '$$? = $?, $$(?D) = $(?D), $$(?F) = $(?F)'
|
|
touch $@
|
|
|
|
$(dir)/bar.y baz.z : ; touch $@
|
|
EOF
|
|
close(MAKEFILE);
|
|
|
|
# TEST #0 -- simple test
|
|
# -------
|
|
|
|
# Touch these into the past
|
|
&utouch(-10, qw(foo.x baz.z));
|
|
|
|
&run_make_with_options($makefile, "", &get_logfile);
|
|
$answer = "touch $dir/bar.y
|
|
\$\@ = $dir/foo.x, \$(\@D) = $dir, \$(\@F) = foo.x
|
|
\$* = $dir/foo, \$(*D) = $dir, \$(*F) = foo
|
|
\$< = baz.z, \$(<D) = ., \$(<F) = baz.z
|
|
\$^ = baz.z $dir/bar.y, \$(^D) = . $dir, \$(^F) = baz.z bar.y
|
|
\$+ = baz.z $dir/bar.y baz.z, \$(+D) = . $dir ., \$(+F) = baz.z bar.y baz.z
|
|
\$? = $dir/bar.y, \$(?D) = $dir, \$(?F) = bar.y
|
|
touch $dir/foo.x\n";
|
|
&compare_output($answer, &get_logfile(1));
|
|
|
|
unlink(qw(foo.x bar.y baz.z));
|
|
|
|
# TEST #1 -- test the SysV emulation of $$@ etc.
|
|
# -------
|
|
|
|
$makefile2 = &get_tmpfile;
|
|
|
|
open(MAKEFILE, "> $makefile2");
|
|
print MAKEFILE "dir = $dir\n";
|
|
print MAKEFILE <<'EOF';
|
|
.SECONDEXPANSION:
|
|
.SUFFIXES:
|
|
.DEFAULT: ; @echo '$@'
|
|
|
|
$(dir)/foo $(dir)/bar: $@.x $$@.x $$$@.x $$$$@.x $$(@D).x $$(@F).x
|
|
|
|
$(dir)/x.z $(dir)/y.z: $(dir)/%.z : $@.% $$@.% $$$@.% $$$$@.% $$(@D).% $$(@F).%
|
|
|
|
$(dir)/biz: $$(@).x $${@}.x $${@D}.x $${@F}.x
|
|
EOF
|
|
|
|
close(MAKEFILE);
|
|
|
|
&run_make_with_options($makefile2, "$dir/foo $dir/bar", &get_logfile);
|
|
$answer = ".x\n$dir/foo.x\nx\n\$@.x\n$dir.x\nfoo.x\n$dir/bar.x\nbar.x\n";
|
|
&compare_output($answer, &get_logfile(1));
|
|
|
|
&run_make_with_options($makefile2, "$dir/x.z $dir/y.z", &get_logfile);
|
|
$answer = ".x\n$dir/x.z.x\nx\n\$@.x\n$dir.x\nx.z.x\n.y\n$dir/y.z.y\ny\n\$@.y\n$dir.y\ny.z.y\n";
|
|
&compare_output($answer, &get_logfile(1));
|
|
|
|
&run_make_with_options($makefile2, "$dir/biz", &get_logfile);
|
|
$answer = "$dir/biz.x\n$dir.x\nbiz.x\n";
|
|
&compare_output($answer, &get_logfile(1));
|
|
|
|
# TEST #2 -- test for Savannah bug #12320.
|
|
#
|
|
run_make_test('
|
|
.SUFFIXES: .b .src
|
|
|
|
mbr.b: mbr.src
|
|
@echo $*
|
|
|
|
mbr.src: ; @:',
|
|
'',
|
|
'mbr');
|
|
|
|
# TEST #3 -- test for Savannah bug #8154
|
|
# Make sure that nonexistent prerequisites are listed in $?, since they are
|
|
# considered reasons for the target to be rebuilt.
|
|
#
|
|
# See also Savannah bugs #16002 and #16051.
|
|
|
|
touch('foo');
|
|
|
|
run_make_test('
|
|
foo: bar ; @echo "\$$? = $?"
|
|
bar: ;',
|
|
'',
|
|
'$? = bar');
|
|
|
|
unlink('foo');
|
|
|
|
# TEST #4: ensure prereq ordering is correct when the commmand target has none
|
|
# See Savannah bug #21198
|
|
|
|
run_make_test('
|
|
all : A B
|
|
all : ; @echo $@ -- $^ -- $<
|
|
all : C D
|
|
all : E F
|
|
A B C D E F G H : ; @:
|
|
',
|
|
'', "all -- A B C D E F -- A\n");
|
|
|
|
1;
|