make-dryrun.tap 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #! /bin/sh
  2. # Copyright (C) 2012-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Check that $(am__make_dryrun) works as expected.
  17. . test-init.sh
  18. plan_ 60
  19. if echo "all: ; +@printf %sbb%s aa cc" | $MAKE -n -f - | grep aabbcc; then
  20. make_plus_silence () { return 0; }
  21. else
  22. make_plus_silence () { return 1; }
  23. fi
  24. mkdir none # Also used later.
  25. if echo nil: | $MAKE -I none -f -; then
  26. make_supports_option_I () { return 0; }
  27. else
  28. make_supports_option_I () { return 1; }
  29. fi
  30. echo AC_OUTPUT >> configure.ac
  31. cat > Makefile.am <<'END'
  32. all:
  33. : Dummy, nothing to do.
  34. run:
  35. @echo ":: $$MAKEFLAGS :: $$MFLAGS ::" ;: For debugging.
  36. $(am__make_dryrun) && exit 1; echo ok > from-run
  37. dry:
  38. +@echo ":: $$MAKEFLAGS :: $$MFLAGS ::" ;: For debugging.
  39. +$(am__make_dryrun) || exit 1; echo ok > from-dry
  40. END
  41. check_make ()
  42. {
  43. msg= mode= condition=: directive= reason= skip_reason=
  44. case $1 in
  45. --dry) mode=dry;;
  46. --run) mode=run;;
  47. *) fatal_ "check_run: invalid usage";;
  48. esac
  49. shift
  50. while test $# -gt 0; do
  51. case $1 in
  52. -C) condition=$2 skip_reason=$3; shift; shift;;
  53. -M) msg=$2; shift;;
  54. --) shift; break;;
  55. *) break;;
  56. esac
  57. shift
  58. done
  59. for opts in '' '-s' '-s -r'; do
  60. r=ok
  61. pmsg=${mode}${msg:+" [$msg]"}${opts:+" ($opts)"}
  62. if $condition; then
  63. $MAKE $opts "$mode" ${1+"$@"} || r='not ok'
  64. test -f from-$mode || r='not ok'
  65. test ! -e bad || r='not ok'
  66. rm -f bad from-* || fatal_ "cleaning up"
  67. else
  68. directive=SKIP reason=$skip_reason
  69. fi
  70. result_ "$r" -D "$directive" -r "$reason" "$pmsg"
  71. done
  72. unset r msg pmsg opts mode condition directive reason skip_reason
  73. }
  74. # ----------------------------------------------------------------------
  75. $ACLOCAL || fatal_ "aclocal failed"
  76. $AUTOCONF || fatal_ "autoconf failed"
  77. $AUTOMAKE || fatal_ "automake failed"
  78. ./configure || fatal_ "configure failed"
  79. # ----------------------------------------------------------------------
  80. check_make --run
  81. # Test against a known regression. This was especially heinous, since
  82. # make running in normal mode was sometimes mistaken for make running
  83. # in dry mode.
  84. check_make --run TESTS="n1.test n2.test"
  85. check_make --run TESTS="n1 n2" AM_MAKEFLAGS="TESTS='n1 n2'"
  86. check_make --run TESTS="n1 n2" AM_MAKEFLAGS='TESTS="n1 n2"'
  87. check_make --run FOOFLAGS="-n -n -knf2 n --none -n"
  88. check_make --run MYFLAGS="-n --dryrun -n --dry-run -n"
  89. # ----------------------------------------------------------------------
  90. check_make --dry -C make_plus_silence 'recipe prefix "+" unsupported' -n
  91. check_make --dry -C using_gmake "\$MAKE is not GNU make" --dry-run -k
  92. # ----------------------------------------------------------------------
  93. # Automake bug#13760: the "n" in "none" used to confound am__make_dryrun
  94. # into thinking the '-n' option had been passed.
  95. pr='bug#13760'
  96. check_make --run -C make_supports_option_I "-I make option unsupported" \
  97. -M "$pr" -I none
  98. check_make --run -C using_gmake "\$MAKE is not GNU make" \
  99. -M "$pr" -I none --include dry-run
  100. check_make --dry -C make_supports_option_I "-I make option unsupported" \
  101. -M "$pr" -I none -n
  102. check_make --dry -C using_gmake "\$MAKE is not GNU make" \
  103. -M "$pr" --dry-run -I none --include dry-run
  104. # ----------------------------------------------------------------------
  105. # Test for when shell metacharacters or backslashes are in $(MAKEFLAGS).
  106. check_metachars ()
  107. {
  108. check_make --run -M "metachars" "$@"
  109. }
  110. check_metachars MYFLAGS="-n \"n\" '-n' --none -n"
  111. check_metachars MYFLAGS='-knf2\ n\ \\n'
  112. check_metachars MYFLAGS="(&) | ; \" \` '"
  113. check_metachars MYFLAGS=" ' # ' "
  114. check_metachars MYFLAGS='$(foo)'
  115. check_metachars MYFLAGS='$(foo -n)'
  116. check_metachars MYFLAGS='`touch bad`'
  117. check_metachars MYFLAGS='`touch --dry-run bad`'
  118. # ----------------------------------------------------------------------
  119. :