add-missing.tap 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. #! /bin/sh
  2. # Copyright (C) 2011-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. # Test that automake complains when required auxiliary files are not
  17. # found, and that 'automake --add-missing' installs the files (and only
  18. # the files) it's supposed to, and that these files are symlinked by
  19. # default, but copied if the '--copy' option is used.
  20. am_create_testdir=empty
  21. . test-init.sh
  22. plan_ "later"
  23. build_aux=build-aux
  24. ocwd=$(pwd) || fatal_ "cannot get current working directory"
  25. # Try to improve readability of displayed diffs.
  26. if diff -u /dev/null /dev/null; then
  27. am_diff='diff -u'
  28. elif diff -c /dev/null /dev/null; then
  29. am_diff='diff -c'
  30. else
  31. am_diff=diff
  32. fi
  33. # MinGW/MSYS lacks real symlinks, so we'll have to skip some checks
  34. # on that system. More details below.
  35. echo dummy > foo
  36. if ln -s foo bar && test -h bar; then
  37. have_true_symlinks=yes
  38. else
  39. have_true_symlinks=no
  40. fi
  41. rm -f foo bar
  42. cat > configure.stub << END
  43. AC_INIT([$me], [1.0])
  44. AC_CONFIG_AUX_DIR([$build_aux])
  45. AM_INIT_AUTOMAKE
  46. AC_CONFIG_FILES([Makefile])
  47. END
  48. # Pre-compute aclocal.m4, in order to save several aclocal invocations.
  49. cat configure.stub - > configure.ac <<'END'
  50. AC_PROG_CC
  51. AC_CANONICAL_BUILD
  52. AC_CANONICAL_HOST
  53. AC_CANONICAL_TARGET
  54. AC_CANONICAL_SYSTEM
  55. AM_PATH_LISPDIR
  56. AM_PATH_PYTHON
  57. AC_OUTPUT
  58. END
  59. $ACLOCAL || framework_failure_ "cannot pre-compute aclocal.m4"
  60. rm -rf configure.ac autom4te*.cache
  61. mv aclocal.m4 aclocal.stub
  62. # For debugging.
  63. cat configure.stub
  64. cat aclocal.stub
  65. check_count=0
  66. # This is hacky and ugly and complex, but allow us to organize our tests
  67. # below in a more "declarative fashion". All in all, a good trade-off.
  68. check_ ()
  69. {
  70. set +x # Temporary disable shell traces to remove noise from log files.
  71. check_count=$(($check_count + 1))
  72. echo check count: $check_count
  73. override=no
  74. run_aclocal=no
  75. fetch_file=
  76. while test $# -gt 0; do
  77. case $1 in
  78. --override) override=yes;;
  79. --run-aclocal) run_aclocal=yes;;
  80. --fetch-file) fetch_file=$2; shift;;
  81. *) framework_failure_ "check_: invalid argument '$1'";;
  82. esac
  83. shift
  84. done
  85. mkdir testdir-$check_count
  86. cd testdir-$check_count
  87. # Directory for common data files (specific to the current test, but
  88. # shared by its "subtests").
  89. mkdir generic
  90. cd generic
  91. : > Makefile.am
  92. if test $override = yes; then
  93. : > configure.ac
  94. else
  95. cp "$ocwd"/configure.stub configure.ac
  96. fi
  97. test -z "$fetch_file" || cp "$ocwd/$fetch_file" .
  98. # Read description of "test scenario" from standard input.
  99. what= line= name= files=
  100. while read line; do
  101. case $line in
  102. '== Name ==') what=NAME;;
  103. '== Makefile.am ==') what=Makefile.am;;
  104. '== configure.ac ==') what=configure.ac;;
  105. '== Files ==') what=LIST;;
  106. '==*') framework_failure_ "invalid input line: $line";;
  107. ''|'#%'*) : Empty line or ad-hoc comment, ignore. ;;
  108. *)
  109. if test $what = LIST; then
  110. files="$files $line"
  111. elif test $what = NAME; then
  112. name=$line
  113. else
  114. printf '%s\n' "$line" >> "$what"
  115. fi
  116. ;;
  117. esac
  118. done
  119. test -n "$name" || fatal_ "name of a test case not specified"
  120. if test $run_aclocal = yes; then
  121. if $ACLOCAL; then
  122. ok_ "[$name] aclocal.m4 rebuilt"
  123. echo == aclocal.m4 ==
  124. cat aclocal.m4
  125. else
  126. not_ok_ "[$name] aclocal failure, aclocal.m4 not rebuilt"
  127. fi
  128. else
  129. cp "$ocwd"/aclocal.stub aclocal.m4
  130. fi
  131. echo == Makefile.am ==
  132. cat Makefile.am
  133. echo == configure.ac ==
  134. cat configure.ac
  135. echo Expected files: $files
  136. mkdir "$build_aux"
  137. cd ..
  138. # End of "test scenario" setup.
  139. set -x # Re-enable shell traces.
  140. pwd
  141. ls -l generic
  142. # Test once with '--copy', once without.
  143. for action in link copy; do
  144. case $action in
  145. link) opts='--add-missing';;
  146. copy) opts='-a --copy';;
  147. *) fatal_ "invalid value '$action' for \$action";;
  148. esac
  149. pfx="[$action $name]"
  150. cp -R generic $action
  151. cd $action
  152. # If the required auxiliary files are missing, and automake is
  153. # not told to install them, it should complain and error out,
  154. # and also give a useful suggestion.
  155. AUTOMAKE_fails -d "$pfx missing files, automake fails"
  156. for f in $files; do
  157. command_ok_ \
  158. "$pfx warn about missing file $f" \
  159. $FGREP "required file '$build_aux/$f' not found" stderr
  160. # Suggest the user to use '--add-missing'.
  161. command_ok_ \
  162. "$pfx suggest --add-missing for $f" \
  163. grep ".*--add-missing.* install .*'$f'" stderr
  164. done
  165. # No files should be automatically installed by automake if it
  166. # is not told to.
  167. if ls "$build_aux" | grep .; then r='not ok'; else r=ok; fi
  168. result_ "$r" "$pfx no extra files installed"
  169. AUTOMAKE_run -d "$pfx automake run successfully" -- $opts
  170. ls -l . $build_aux
  171. # The expected files should get installed correctly (e.g., no
  172. # broken symlinks).
  173. for f in $files; do
  174. command_ok_ \
  175. "$pfx file $f installed" \
  176. test -f $build_aux/$f
  177. done
  178. # Automake should inform about which files it's installing.
  179. for f in $files; do
  180. command_ok_ \
  181. "$pfx report installation of $f" \
  182. $FGREP ": installing '$build_aux/$f'" stderr
  183. done
  184. # Only the expected files should be installed. But automake always
  185. # require 'missing' and 'install-sh', so account for them.
  186. all_files="install-sh missing $files"
  187. for f in $all_files; do echo $f; done | sort | uniq > files.exp
  188. (cd $build_aux && ls) | sort > files.got
  189. cat files.exp
  190. cat files.got
  191. command_ok_ \
  192. "$pfx all and only expected files installed" \
  193. $am_diff files.exp files.got
  194. # The files should be copied by '--copy' and symlinked otherwise.
  195. # But these checks make no sense on systems like MSYS/MinGW where
  196. # there are no true symlinks ('ln -s' behaves like 'cp -p'), so be
  197. # ready to skip the checks in that case. See automake bug#10441.
  198. for f in $files; do
  199. if test $have_true_symlinks = no; then
  200. skip_ -r "system lacks true symlinks" "$pfx $f is a symlink or not"
  201. else
  202. if test -h $build_aux/$f; then
  203. is_symlink=yes
  204. else
  205. is_symlink=no
  206. fi
  207. case $action,$is_symlink in
  208. link,yes) ok_ "$pfx $f has been symlinked" ;;
  209. link,no) not_ok_ "$pfx $f has not been symlinked" ;;
  210. copy,yes) not_ok_ "$pfx $f has been symlinked" ;;
  211. copy,no) ok_ "$pfx $f has not been symlinked" ;;
  212. *) fatal_ "invalid condition in case" ;;
  213. esac
  214. fi
  215. done
  216. # Now that the required auxiliary files have been installed, automake
  217. # should not complain anymore even if the '--add-missing' option is
  218. # not used.
  219. AUTOMAKE_run -d "$pfx automake finds all added files"
  220. cd ..
  221. done # for action in link copy
  222. cd "$ocwd" || fatal_ "cannot chdir back to top-level test directory"
  223. }
  224. # Automake should always and unconditionally require the 'missing'
  225. # and 'install-sh' scripts.
  226. check_ <<'END'
  227. == Name ==
  228. minimal
  229. == Files ==
  230. install-sh missing
  231. END
  232. check_ <<'END'
  233. == Name ==
  234. depcomp/C
  235. == Files ==
  236. depcomp
  237. compile
  238. == configure.ac ==
  239. AC_PROG_CC
  240. == Makefile.am ==
  241. bin_PROGRAMS = foo
  242. END
  243. check_ <<'END'
  244. == Name ==
  245. depcomp/C++
  246. == Files ==
  247. depcomp
  248. == configure.ac ==
  249. AC_PROG_CXX
  250. == Makefile.am ==
  251. bin_PROGRAMS = foo
  252. foo_SOURCES = foo.cc
  253. END
  254. check_ --run-aclocal <<'END'
  255. == Name ==
  256. compile
  257. == Files ==
  258. compile
  259. == configure.ac ==
  260. # Using AC_PROG_CC in configure.ac should be enough.
  261. # No need to also define, say, xxx_PROGRAMS in Makefile.am.
  262. AC_PROG_CC
  263. END
  264. # For config.guess and config.sub.
  265. for mach in build host target system; do
  266. MACH=$(echo "$mach" | LC_ALL=C tr '[a-z]' '[A-Z]')
  267. check_ <<END
  268. == Name ==
  269. cfg-$mach
  270. == Files ==
  271. config.sub
  272. config.guess
  273. == configure.ac ==
  274. AC_CANONICAL_$MACH
  275. END
  276. done
  277. check_ <<'END'
  278. == Name ==
  279. ylwrap/Lex
  280. == Files ==
  281. ylwrap
  282. compile
  283. == configure.ac ==
  284. AC_PROG_CC
  285. AC_PROG_LEX
  286. == Makefile.am ==
  287. AUTOMAKE_OPTIONS = no-dependencies
  288. bin_PROGRAMS = foo
  289. foo_SOURCES = foo.l
  290. END
  291. check_ <<'END'
  292. == Name ==
  293. ylwrap/Yacc
  294. == Files ==
  295. ylwrap
  296. compile
  297. == configure.ac ==
  298. AC_PROG_CC
  299. AC_PROG_YACC
  300. == Makefile.am ==
  301. AUTOMAKE_OPTIONS = no-dependencies
  302. bin_PROGRAMS = foo
  303. foo_SOURCES = foo.y
  304. END
  305. echo '@setfilename foo.info' > foo.texi
  306. check_ --fetch-file foo.texi <<'END'
  307. == Name ==
  308. Texinfo
  309. == Files ==
  310. texinfo.tex
  311. == Makefile.am ==
  312. info_TEXINFOS = foo.texi
  313. END
  314. echo '@include version.texi' >> foo.texi
  315. check_ --fetch-file foo.texi <<'END'
  316. == Name ==
  317. Texinfo/mdate-sh
  318. == Files ==
  319. mdate-sh
  320. texinfo.tex
  321. == Makefile.am ==
  322. info_TEXINFOS = foo.texi
  323. END
  324. rm -f foo.texi
  325. check_ <<'END'
  326. == Name ==
  327. py-compile
  328. == Files ==
  329. py-compile
  330. == configure.ac ==
  331. AM_PATH_PYTHON
  332. == Makefile.am ==
  333. python_PYTHON = foo.py
  334. END
  335. # Try few unrelated auxiliary scripts together.
  336. check_ <<'END'
  337. == Name ==
  338. misc
  339. == Files ==
  340. py-compile
  341. depcomp
  342. ylwrap
  343. config.sub
  344. config.guess
  345. == configure.ac ==
  346. AC_CANONICAL_BUILD
  347. AC_CANONICAL_HOST
  348. AC_PROG_CXX
  349. == Makefile.am ==
  350. PYTHON = python
  351. pythondir = $(prefix)/py
  352. YACC = bison -y
  353. bin_PROGRAMS = foo
  354. foo_SOURCES = bar.yxx baz.c++
  355. python_PYTHON = zardoz.py
  356. END
  357. :