Fix -W foo yielding infinite recursion in some cases of re-exec.

Added a -W test suite.
This commit is contained in:
Paul Smith 2005-06-25 20:00:24 +00:00
parent 978819e1d6
commit 1dd9ed1c05
4 changed files with 77 additions and 4 deletions

View file

@ -13,6 +13,10 @@
(main): When checking makefiles, only set always_make_flag if
always_make_set is set AND the restarts flag is 0. When building
normal targets, set it IFF always_make_set is set.
(main): Avoid infinite recursion with -W, too: only set what-if
files to NEW before we check makefiles if we've never restarted
before. If we have restarted, set what-if files to NEW _after_ we
check makefiles.
2005-06-17 Paul D. Smith <psmith@gnu.org>

18
main.c
View file

@ -1772,9 +1772,9 @@ main (int argc, char **argv, char **envp)
build_vpath_lists ();
/* Mark files given with -o flags as very old
and as having been updated already, and files given with -W flags as
brand new (time-stamp as far as possible into the future). */
/* Mark files given with -o flags as very old and as having been updated
already, and files given with -W flags as brand new (time-stamp as far
as possible into the future). If restarts is set we'll do -W later. */
if (old_files != 0)
for (p = old_files->list; *p != 0; ++p)
@ -1786,7 +1786,7 @@ main (int argc, char **argv, char **envp)
f->command_state = cs_finished;
}
if (new_files != 0)
if (!restarts && new_files != 0)
{
for (p = new_files->list; *p != 0; ++p)
{
@ -2117,6 +2117,16 @@ main (int argc, char **argv, char **envp)
/* Set always_make_flag if -B was given. */
always_make_flag = always_make_set;
/* If restarts is set we haven't set up -W files yet, so do that now. */
if (restarts && new_files != 0)
{
for (p = new_files->list; *p != 0; ++p)
{
f = enter_command_line_file (*p);
f->last_mtime = f->mtime_before_update = NEW_MTIME;
}
}
/* If there is a temp file from reading a makefile from stdin, get rid of
it now. */
if (stdin_nm && unlink (stdin_nm) < 0 && errno != ENOENT)

View file

@ -4,6 +4,8 @@
MAKE_RESTARTS variable.
* scripts/options/dash-B: Test re-exec doesn't loop infinitely.
Tests fix for Savannah bug #7566.
* scripts/options/dash-W: New file: test the -W flag, including
re-exec infinite looping.
2005-06-12 Paul D. Smith <psmith@gnu.org>

View file

@ -0,0 +1,57 @@
# -*-perl-*-
$description = "Test make -W (what if) option.\n";
# Basic build
run_make_test('
a.x: b.x
a.x b.x: ; touch $@
',
'', "touch b.x\ntouch a.x");
# Run it again: nothing should happen
run_make_test(undef, '', "#MAKE#: `a.x' is up to date.");
# Now run it with -W b.x: should rebuild a.x
run_make_test(undef, '-W b.x', 'touch a.x');
# Put the timestamp for a.x into the future; it should still be remade.
utouch(1000, 'a.x');
run_make_test(undef, '', "#MAKE#: `a.x' is up to date.");
run_make_test(undef, '-W b.x', 'touch a.x');
# 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 $@"
bar.x: ; touch $@
baz.x: bar.x ; @echo "touch $@"
',
'', '#MAKEFILE#:3: foo.x: No such file or directory
touch bar.x
touch foo.x
restarts=1
touch baz.x');
# Now run with -W bar.x
run_make_test(undef, '-W bar.x', "restarts=\ntouch foo.x\nrestarts=1\ntouch baz.x");
rmfiles('foo.x', 'bar.x');
1;