cscope.tap 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #! /bin/sh
  2. # Copyright (C) 2009-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 cscope functionality.
  17. . test-init.sh
  18. plan_ 18
  19. ocwd=$(pwd) || fatal_ "getting top-level directory"
  20. cat > configure.ac << 'END'
  21. AC_INIT([cscope-test], [1.0])
  22. AM_INIT_AUTOMAKE([subdir-objects])
  23. AC_CONFIG_FILES([Makefile sub/Makefile])
  24. AC_SUBST([CC], [who-cares])
  25. AC_SUBST([CXX], [who-cares])
  26. AC_SUBST([FC], [who-cares])
  27. AC_SUBST([GCJ], [who-cares])
  28. AM_PATH_LISPDIR
  29. AC_OUTPUT
  30. END
  31. mkdir sub sub/subsub
  32. cat > Makefile.am <<'END'
  33. SUBDIRS = sub
  34. bin_PROGRAMS = foo
  35. foo_SOURCES = foo.c bar.cpp baz.f90
  36. lisp_LISP = foo.el
  37. EXTRA_DIST = foo.el
  38. END
  39. cat > sub/Makefile.am <<'END'
  40. bin_PROGRAMS = bar
  41. bar_SOURCES = subsub/dist.c
  42. nodist_bar_SOURCES = subsub/gen.c
  43. subsub/gen.c:
  44. $(MKDIR_P) subsub
  45. echo 'int generated_subsub () { return 0; }' > $@
  46. CLEANFILES = subsub/gen.c
  47. END
  48. echo 'int foo_func () { return 0; }' > foo.c
  49. echo 'int main () { return 0; }' > bar.cpp
  50. cat > baz.f90 <<'END'
  51. subroutine baz
  52. end
  53. END
  54. : > foo.el
  55. echo 'int main () { return 0; }' > sub/subsub/dist.c
  56. $ACLOCAL || fatal_ "aclocal failed"
  57. $AUTOCONF || fatal_ "autoconf failed"
  58. $AUTOMAKE -i -a || fatal_ "automake -i -a failed"
  59. # Sun cscope is interactive without redirection; also, it might not
  60. # support the '-q' option, which is required by our generated recipes.
  61. if cscope -q --version </dev/null; then
  62. have_cscope=yes
  63. else
  64. have_cscope=no
  65. fi
  66. test_cleanup ()
  67. {
  68. r=ok
  69. if test -f configure; then
  70. # In-tree build.
  71. $MAKE distclean
  72. else
  73. # VPATH build.
  74. $MAKE distcleancheck
  75. fi \
  76. && test ! -e cscope.files \
  77. && test ! -e cscope.out \
  78. && test ! -e cscope.in.out \
  79. && test ! -e cscope.po.out \
  80. || r='not ok'
  81. result_ "$r" "[$pfx] make distcheck"
  82. }
  83. test_cscope ()
  84. {
  85. r=ok
  86. $MAKE -n cscope || r='not ok'
  87. result_ "$r" "[$pfx] make -n cscope"
  88. if test $have_cscope = no; then
  89. # For later tests.
  90. touch cscope.files cscope.out cscope.in.out cscope.po.out
  91. skip_row_ 3 -r "no proper cscope program available"
  92. return 0
  93. fi
  94. r=ok
  95. run_make -E cscope || r='not ok'
  96. grep 'cannot find file' stderr && r='not ok'
  97. rm -f stderr
  98. result_ "$r" "[$pfx] make cscope"
  99. r=ok
  100. test -f cscope.files \
  101. && $FGREP foo.c cscope.files \
  102. && $FGREP bar.cpp cscope.files \
  103. && $FGREP sub/subsub/dist.c cscope.files \
  104. && $FGREP sub/subsub/gen.c cscope.files \
  105. || r='not ok'
  106. result_ "$r" "[$pfx] cscope.files looks correct"
  107. r=ok
  108. # cscope.files might not exist of the earlier "make cscope" failed.
  109. cp cscope.files cscope.files1 \
  110. && $MAKE cscope \
  111. && diff cscope.files cscope.files1 \
  112. || r='not ok'
  113. rm -f cscope.files1
  114. result_ "$r" "[$pfx] second \"make cscope\" is consistent"
  115. }
  116. my_configure ()
  117. {
  118. command_ok_ "[$pfx] configure" \
  119. "$1"/configure EMACS=no --with-lispdir=/who/cares
  120. }
  121. if using_gmake; then
  122. cd "$ocwd"
  123. pfx="relative VPATH"
  124. mkdir build
  125. cd build
  126. my_configure ..
  127. test_cscope
  128. test_cleanup
  129. cd "$ocwd"
  130. pfx="absolute VPATH"
  131. mkdir build2
  132. cd build2
  133. my_configure "$ocwd"
  134. test_cscope
  135. test_cleanup
  136. else
  137. skip_row_ 12 -r "cscope in VPATH requires GNU make"
  138. fi
  139. cd "$ocwd"
  140. pfx="in-tree build"
  141. my_configure .
  142. test_cscope
  143. test_cleanup
  144. :