reinvoke 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # -*-mode: perl-*-
  2. $description = "Test GNU make's auto-reinvocation feature.";
  3. $details = "\
  4. If the makefile or one it includes can be rebuilt then it is, and make
  5. is reinvoked. We create a rule to rebuild the makefile from a temp
  6. file, then touch the temp file to make it newer than the makefile.";
  7. $makefile2 = &get_tmpfile;
  8. $makefile_orig = &get_tmpfile;
  9. open(MAKEFILE,"> $makefile");
  10. print MAKEFILE <<EOM;
  11. all: ; \@echo 'running rules.'
  12. $makefile $makefile2: $makefile_orig
  13. \@echo 'rebuilding \$\@.'
  14. \@echo >> \$\@
  15. include $makefile2
  16. EOM
  17. close(MAKEFILE);
  18. &touch($makefile2);
  19. # Sleep 2 seconds for DOS/Windows FAT volumes which have 2-second
  20. # granularity of file times.
  21. sleep(2);
  22. &touch("$makefile_orig");
  23. &run_make_with_options($makefile, "", &get_logfile, 0);
  24. # Create the answer to what should be produced by this Makefile
  25. $answer = "rebuilding $makefile2.\nrebuilding $makefile.\nrunning rules.\n";
  26. &compare_output($answer,&get_logfile(1))
  27. && unlink "$makefile_orig";
  28. # In this test we create an included file that's out-of-date, but then
  29. # the rule doesn't update it. Make shouldn't re-exec.
  30. $makefile3 = &get_tmpfile;
  31. open(MAKEFILE, "> $makefile3");
  32. print MAKEFILE <<'EOM';
  33. SHELL = /bin/sh
  34. all: ; @echo hello
  35. a : b ; echo >> $@
  36. b : c ; [ -f $@ ] || echo >> $@
  37. c: ; echo >> $@
  38. include $(F)
  39. EOM
  40. close(MAKEFILE);
  41. &touch('b');
  42. &touch('a');
  43. sleep(2);
  44. &touch('c');
  45. # First try with the file that's not updated "once removed" from the
  46. # file we're including.
  47. &run_make_with_options($makefile3, "F=a", &get_logfile, 0);
  48. $answer = "[ -f b ] || echo >> b\nhello\n";
  49. &compare_output($answer,&get_logfile(1));
  50. # Now try with the file we're not updating being the actual file we're
  51. # including: this and the previous one test different parts of the code.
  52. &run_make_with_options($makefile3, "F=b", &get_logfile, 0);
  53. $answer = "[ -f b ] || echo >> b\nhello\n";
  54. &compare_output($answer,&get_logfile(1));
  55. unlink('a','b','c');
  56. # This tells the test driver that the perl test script executed properly.
  57. 1;