2005-06-25 20:00:24 +00:00
|
|
|
# -*-perl-*-
|
|
|
|
|
|
|
|
$description = "Test make -W (what if) option.\n";
|
|
|
|
|
|
|
|
# Basic build
|
|
|
|
|
|
|
|
run_make_test('
|
|
|
|
a.x: b.x
|
2005-06-27 22:18:47 +00:00
|
|
|
a.x b.x: ; echo >> $@
|
2005-06-25 20:00:24 +00:00
|
|
|
',
|
2005-06-27 22:18:47 +00:00
|
|
|
'', "echo >> b.x\necho >> a.x");
|
2005-06-25 20:00:24 +00:00
|
|
|
|
|
|
|
# Run it again: nothing should happen
|
|
|
|
|
2012-03-04 00:24:20 +00:00
|
|
|
run_make_test(undef, '', "#MAKE#: 'a.x' is up to date.");
|
2005-06-25 20:00:24 +00:00
|
|
|
|
|
|
|
# Now run it with -W b.x: should rebuild a.x
|
|
|
|
|
2005-06-27 22:18:47 +00:00
|
|
|
run_make_test(undef, '-W b.x', 'echo >> a.x');
|
2005-06-25 20:00:24 +00:00
|
|
|
|
|
|
|
# Put the timestamp for a.x into the future; it should still be remade.
|
|
|
|
|
|
|
|
utouch(1000, 'a.x');
|
2012-03-04 00:24:20 +00:00
|
|
|
run_make_test(undef, '', "#MAKE#: 'a.x' is up to date.");
|
2005-06-27 22:18:47 +00:00
|
|
|
run_make_test(undef, '-W b.x', 'echo >> a.x');
|
2005-06-25 20:00:24 +00:00
|
|
|
|
|
|
|
# Clean up
|
|
|
|
|
|
|
|
rmfiles('a.x', 'b.x');
|
|
|
|
|
|
|
|
# Test -W with the re-exec feature: we don't want to re-exec forever
|
|
|
|
# Savannah bug # 7566
|
|
|
|
|
|
|
|
# First set it up with a normal build
|
|
|
|
|
|
|
|
run_make_test('
|
|
|
|
all: baz.x ; @:
|
|
|
|
include foo.x
|
|
|
|
foo.x: bar.x
|
|
|
|
@echo "\$$(info restarts=\$$(MAKE_RESTARTS))" > $@
|
|
|
|
@echo "touch $@"
|
2005-06-27 22:18:47 +00:00
|
|
|
bar.x: ; echo >> $@
|
2005-06-25 20:00:24 +00:00
|
|
|
baz.x: bar.x ; @echo "touch $@"
|
|
|
|
',
|
|
|
|
'', '#MAKEFILE#:3: foo.x: No such file or directory
|
2005-06-27 22:18:47 +00:00
|
|
|
echo >> bar.x
|
2005-06-25 20:00:24 +00:00
|
|
|
touch foo.x
|
|
|
|
restarts=1
|
|
|
|
touch baz.x');
|
|
|
|
|
|
|
|
# Now run with -W bar.x
|
|
|
|
|
2005-06-27 18:53:46 +00:00
|
|
|
# Tweak foo.x's timestamp so the update will change it.
|
2005-06-27 22:18:47 +00:00
|
|
|
&utouch(1000, 'foo.x');
|
2005-06-27 18:53:46 +00:00
|
|
|
|
2005-06-25 20:00:24 +00:00
|
|
|
run_make_test(undef, '-W bar.x', "restarts=\ntouch foo.x\nrestarts=1\ntouch baz.x");
|
|
|
|
|
|
|
|
rmfiles('foo.x', 'bar.x');
|
|
|
|
|
2006-02-06 16:21:59 +00:00
|
|
|
# Test -W on vpath-found files: it should take effect.
|
|
|
|
# Savannah bug # 15341
|
|
|
|
|
2006-03-08 20:15:08 +00:00
|
|
|
mkdir('x-dir', 0777);
|
2006-02-06 16:21:59 +00:00
|
|
|
utouch(-20, 'x-dir/x');
|
|
|
|
touch('y');
|
|
|
|
|
|
|
|
run_make_test('
|
|
|
|
y: x ; @echo cp $< $@
|
|
|
|
',
|
|
|
|
'-W x-dir/x VPATH=x-dir',
|
|
|
|
'cp x-dir/x y');
|
|
|
|
|
|
|
|
# Make sure ./ stripping doesn't interfere with the match.
|
|
|
|
|
|
|
|
run_make_test('
|
|
|
|
y: x ; @echo cp $< $@
|
|
|
|
',
|
|
|
|
'-W ./x-dir/x VPATH=x-dir',
|
|
|
|
'cp x-dir/x y');
|
|
|
|
|
|
|
|
run_make_test(undef,
|
|
|
|
'-W x-dir/x VPATH=./x-dir',
|
|
|
|
'cp ./x-dir/x y');
|
|
|
|
|
|
|
|
unlink(qw(y x-dir/x));
|
|
|
|
rmdir('x-dir');
|
|
|
|
|
2005-06-25 20:00:24 +00:00
|
|
|
1;
|