summaryrefslogtreecommitdiff
path: root/t/ctags.sh
blob: 342748f62cdcf707a427f713d16ff9ac66ba9d3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#! /bin/sh
# Copyright (C) 2012-2014 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Test vi-style tags.

required=${CTAGS:=ctags}
. test-init.sh

cat >> configure.ac << 'END'
AC_SUBST([CC], [false])
AM_CONDITIONAL([COND_FALSE], [false])
AC_CONFIG_FILES([sub1/Makefile
                 sub3/Makefile
                 sub2/Makefile
                 sub2/subsub/Makefile])
AC_OUTPUT
END

mkdir sub1 sub2 sub3 sub2/subsub

cat > Makefile.am << 'END'
SUBDIRS = sub1 sub2 sub3
test-ctags: ctags
	test ! -f tags
	cat sub1/tags
	cat sub2/tags
	cat sub2/subsub/tags
	test ! -f sub3/tags
	grep 'iguana\.c' sub1/tags
	grep 'zap_zap' sub1/tags
	grep 'main' sub1/tags
	grep 'choke_me' sub1/tags && exit 1; :
	grep 'subsub/foo\.h' sub2/tags
	grep 'IsBigger' sub2/tags
	grep 'bar\.f77' sub2/subsub/tags
	grep 'foo\.cxx' sub2/subsub/tags
	grep 'foo\.h' sub2/subsub/tags && exit 1; :
check-local: test-ctags
END

cat > sub1/Makefile.am << 'END'
if COND_FALSE
bin_PROGRAMS = iguana
endif
END

cat > sub1/iguana.c <<'END'
int main (void) { return zap_zap (0); }

int
zap_zap (int x)
{
  return x + choke_me ();
}
END

cat > sub2/Makefile.am << 'END'
SUBDIRS = subsub .
noinst_HEADERS = subsub/foo.h
subsub/foo.h:
	# Use and inlined function, not a #define, for the sake of
	# Emacs and XEmacs ctags (at least up to version 23).
	echo 'inline int IsBigger (int a, int b) { return (a > b); }' >$@
CLEANFILES = $(noinst_HEADERS)
END

cat > sub2/subsub/Makefile.am << 'END'
TAGS_FILES =
EXTRA_DIST = bar.f77
TAGS_FILES += bar.f77
nodist_noinst_DATA = foo.cxx
TAGS_FILES += foo.cxx
CLEANFILES = foo.cxx
foo.cxx:
	echo "int cxx_func (void) { return 0; }" >$@
END

cat > sub2/subsub/bar.f77 << 'END'
      subroutine foobarbaz
      return
      end
END

# No files to tag here, deliberately.
: > sub3/Makefile.am

$ACLOCAL
$AUTOCONF
$AUTOMAKE -i

./configure
$MAKE test-ctags CTAGS="$CTAGS"
$MAKE distcheck CTAGS="$CTAGS"

$MAKE distclean
find . -name tags | grep . && exit 1

: