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