double_colon 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # -*-perl-*-
  2. $description = "Test handling of double-colon rules.";
  3. $details = "\
  4. We test these features:
  5. - Multiple commands for the same (double-colon) target
  6. - Different prerequisites for targets: only out-of-date
  7. ones are rebuilt.
  8. - Double-colon targets that aren't the goal target.
  9. Then we do the same thing for parallel builds: double-colon
  10. targets should always be built serially.";
  11. # The Contents of the MAKEFILE ...
  12. open(MAKEFILE,"> $makefile");
  13. print MAKEFILE <<'EOF';
  14. all: baz
  15. foo:: f1.h ; @echo foo FIRST
  16. foo:: f2.h ; @echo foo SECOND
  17. bar:: ; @echo aaa; sleep 1; echo aaa done
  18. bar:: ; @echo bbb
  19. baz:: ; @echo aaa
  20. baz:: ; @echo bbb
  21. biz:: ; @echo aaa
  22. biz:: two ; @echo bbb
  23. two: ; @echo two
  24. f1.h f2.h: ; @echo $@
  25. d :: ; @echo ok
  26. d :: d ; @echo oops
  27. EOF
  28. close(MAKEFILE);
  29. # TEST 0: A simple double-colon rule that isn't the goal target.
  30. &run_make_with_options($makefile, "all", &get_logfile, 0);
  31. $answer = "aaa\nbbb\n";
  32. &compare_output($answer, &get_logfile(1));
  33. # TEST 1: As above, in parallel
  34. &run_make_with_options($makefile, "-j10 all", &get_logfile, 0);
  35. $answer = "aaa\nbbb\n";
  36. &compare_output($answer, &get_logfile(1));
  37. # TEST 2: A simple double-colon rule that is the goal target
  38. &run_make_with_options($makefile, "bar", &get_logfile, 0);
  39. $answer = "aaa\naaa done\nbbb\n";
  40. &compare_output($answer, &get_logfile(1));
  41. # TEST 3: As above, in parallel
  42. &run_make_with_options($makefile, "-j10 bar", &get_logfile, 0);
  43. $answer = "aaa\naaa done\nbbb\n";
  44. &compare_output($answer, &get_logfile(1));
  45. # TEST 4: Each double-colon rule is supposed to be run individually
  46. &touch('f2.h');
  47. &touch('foo');
  48. &run_make_with_options($makefile, "foo", &get_logfile, 0);
  49. $answer = "f1.h\nfoo FIRST\n";
  50. &compare_output($answer, &get_logfile(1));
  51. # TEST 5: Again, in parallel.
  52. &run_make_with_options($makefile, "-j10 foo", &get_logfile, 0);
  53. $answer = "f1.h\nfoo FIRST\n";
  54. &compare_output($answer, &get_logfile(1));
  55. # TEST 6: Each double-colon rule is supposed to be run individually
  56. &touch('f1.h');
  57. unlink('f2.h');
  58. &touch('foo');
  59. &run_make_with_options($makefile, "foo", &get_logfile, 0);
  60. $answer = "f2.h\nfoo SECOND\n";
  61. &compare_output($answer, &get_logfile(1));
  62. # TEST 7: Again, in parallel.
  63. &run_make_with_options($makefile, "-j10 foo", &get_logfile, 0);
  64. $answer = "f2.h\nfoo SECOND\n";
  65. &compare_output($answer, &get_logfile(1));
  66. # TEST 8: Test circular dependency check; PR/1671
  67. &run_make_with_options($makefile, "d", &get_logfile, 0);
  68. $answer = "ok\n$make_name: Circular d <- d dependency dropped.\noops\n";
  69. &compare_output($answer, &get_logfile(1));
  70. # TEST 8: I don't grok why this is different than the above, but it is...
  71. #
  72. # Hmm... further testing indicates this might be timing-dependent?
  73. #
  74. #&run_make_with_options($makefile, "-j10 biz", &get_logfile, 0);
  75. #$answer = "aaa\ntwo\nbbb\n";
  76. #&compare_output($answer, &get_logfile(1));
  77. unlink('foo','f1.h','f2.h');
  78. 1;