diff options
author | Paul Smith <psmith@gnu.org> | 2005-06-25 20:00:24 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2005-06-25 20:00:24 +0000 |
commit | 1cbb15f2545882ded5df14363ad289383d9c66ff (patch) | |
tree | b30f0c7714fdf3d7450cf4ddca8a485572ff7631 | |
parent | deba861009c97a0d13c30c6162fda7c7451203b8 (diff) | |
download | make-1cbb15f2545882ded5df14363ad289383d9c66ff.tar.gz |
Fix -W foo yielding infinite recursion in some cases of re-exec.
Added a -W test suite.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | main.c | 18 | ||||
-rw-r--r-- | tests/ChangeLog | 2 | ||||
-rw-r--r-- | tests/scripts/options/dash-W | 57 |
4 files changed, 77 insertions, 4 deletions
@@ -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> @@ -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) diff --git a/tests/ChangeLog b/tests/ChangeLog index 90fbf7d9..be5169b4 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -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> diff --git a/tests/scripts/options/dash-W b/tests/scripts/options/dash-W new file mode 100644 index 00000000..9a12d9a2 --- /dev/null +++ b/tests/scripts/options/dash-W @@ -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; |