1# -*-perl-*- 2 3$description = "Test make -W (what if) option.\n"; 4 5# Basic build 6 7run_make_test(' 8a.x: b.x 9a.x b.x: ; echo >> $@ 10', 11 '', "echo >> b.x\necho >> a.x"); 12 13# Run it again: nothing should happen 14 15run_make_test(undef, '', "#MAKE#: `a.x' is up to date."); 16 17# Now run it with -W b.x: should rebuild a.x 18 19run_make_test(undef, '-W b.x', 'echo >> a.x'); 20 21# Put the timestamp for a.x into the future; it should still be remade. 22 23utouch(1000, 'a.x'); 24run_make_test(undef, '', "#MAKE#: `a.x' is up to date."); 25run_make_test(undef, '-W b.x', 'echo >> a.x'); 26 27# Clean up 28 29rmfiles('a.x', 'b.x'); 30 31# Test -W with the re-exec feature: we don't want to re-exec forever 32# Savannah bug # 7566 33 34# First set it up with a normal build 35 36run_make_test(' 37all: baz.x ; @: 38include foo.x 39foo.x: bar.x 40 @echo "\$$(info restarts=\$$(MAKE_RESTARTS))" > $@ 41 @echo "touch $@" 42bar.x: ; echo >> $@ 43baz.x: bar.x ; @echo "touch $@" 44', 45 '', '#MAKEFILE#:3: foo.x: No such file or directory 46echo >> bar.x 47touch foo.x 48restarts=1 49touch baz.x'); 50 51# Now run with -W bar.x 52 53# Tweak foo.x's timestamp so the update will change it. 54&utouch(1000, 'foo.x'); 55 56run_make_test(undef, '-W bar.x', "restarts=\ntouch foo.x\nrestarts=1\ntouch baz.x"); 57 58rmfiles('foo.x', 'bar.x'); 59 60# Test -W on vpath-found files: it should take effect. 61# Savannah bug # 15341 62 63mkdir('x-dir', 0777); 64utouch(-20, 'x-dir/x'); 65touch('y'); 66 67run_make_test(' 68y: x ; @echo cp $< $@ 69', 70 '-W x-dir/x VPATH=x-dir', 71 'cp x-dir/x y'); 72 73# Make sure ./ stripping doesn't interfere with the match. 74 75run_make_test(' 76y: x ; @echo cp $< $@ 77', 78 '-W ./x-dir/x VPATH=x-dir', 79 'cp x-dir/x y'); 80 81run_make_test(undef, 82 '-W x-dir/x VPATH=./x-dir', 83 'cp ./x-dir/x y'); 84 85unlink(qw(y x-dir/x)); 86rmdir('x-dir'); 87 881; 89