File: testing-ctags.rst

package info (click to toggle)
universal-ctags 5.9.20210829.0-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 28,024 kB
  • sloc: ansic: 133,059; lisp: 7,664; sh: 7,352; vhdl: 6,517; python: 2,234; perl: 2,229; cpp: 2,099; javascript: 1,576; cs: 1,193; cobol: 741; makefile: 740; sql: 674; php: 666; f90: 534; ruby: 498; yacc: 459; ada: 393; asm: 358; fortran: 345; xml: 308; objc: 289; tcl: 221; java: 157; erlang: 61; ml: 49; awk: 44; haskell: 36
file content (162 lines) | stat: -rw-r--r-- 4,684 bytes parent folder | download | duplicates (5)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
.. _testing_ctags:

=============================================================================
Testing ctags
=============================================================================

.. contents:: `Table of contents`
	:depth: 1
	:local:

..	tmain.rst

*Tmain*: a facility for testing main part
------------------------------------------------------------

:Maintainer: Masatake YAMATO <yamato@redhat.com>

----

*Tmain* is introduced to test the area where *Units*
does not cover well.

*Units* works fine for testing parsers. However, it
assumes something input is given to ctags command,
and a `tags` file is generated from ctags command.

Other aspects cannot be tested. Such areas are files
and directories layout after installation, standard
error output, exit status, etc.

You can run test cases with following command line:

::

	$ make tmain

*Tmain* is still under development so I will not write
the details here.


To write a test case, see files under `Tmain/tmain-example.d`.
In the example, *Tmain* does:

1. runs new subshell and change the working directory to `Tmain/tmain-example.d`,
2. runs `run.sh` with `bash`,
3. captures stdout, stderr and exit status, and
4. compares them with `stdout-expected.txt`, `stderr-expected.txt`,
   and `exit-expected.txt`.
5. compares it with `tags-expected.txt` if run.sh generates `tags` file.

`run.sh` is run with following 3 arguments:

1. the path for the target ctags
2. the path for `builddir` directory
3. the path for the target readtags

The path for readtags is not reliable; readtags command is not
available if --disable-readcmd was given in configure time.  A case,
testing the behavior of readtags, must verify the command existence
with `test -x $3` before going into the main part of the test.

When comparing `tags` file with `tags-expected.txt`, you
must specify the path of `tags` explicitly with -o option
in ctags command line like::

	CTAGS=$1
	BUILDDIR=$2
	${CTAGS} ... -o $BUILDDIR/tags ...

This makes it possible to keep the original source directory clean.

See also `tmain_run` and `tmain_compare` functions in `misc/units`.

If run.sh exits with code 77, the test case is skipped.
The output to stdout is captured and printed as the reason
of skipping.

TODO
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Run under valgrind

..	tinst.rst

*Tinst*: installation test
---------------------------------------------------------------------

:Maintainer: Masatake YAMATO <yamato@redhat.com>

-----

tinst target is for testing the result of ``make install``.

::

   $ make tinst

Fussy syntax checking
------------------------------------------------------------
If ``-Wall`` of gcc is not enough, you may be interested in this.

You can change C compiler warning options with 'WARNING_CFLAGS'
configure arg-var option.

::

   $ ./configure WARNING_CFLAGS='-Wall -Wextra'


If configure option '--with-sparse-cgcc' is specified,
cgcc is used as CC. cgcc is part of `Sparse, Semantic Parser for C
<https://sparse.docs.kernel.org/en/latest/>`_.
It is used in development of Linux kernel for finding programming error.
cgcc acts as a c compiler but more fussy. '-Wsparse-all' is used as
default option passed to cgcc but you can change with 'CGCC_CFLAGS'
configure arg-var option.

::

   $ ./configure --with-sparse-cgcc [CGCC_CFLAGS='-Wsparse-all']


Finding performance bottleneck
------------------------------------------------------------

See `Profiling with gperftools
<https://wiki.geany.org/howtos/profiling/gperftools>`_ and `#383
<https://github.com/universal-ctags/ctags/issues/383>`_.

See also `codebase <https://github.com/universal-ctags/codebase>`_.

Checking coverage
------------------------------------------------------------
Before starting coverage measuring, you need to specify
'--enable-coverage-gcov' configure option.

::

   $ ./configure --enable-coverage-gcov


After doing ``make clean``, you can build coverage measuring ready
ctags by ``make``. At this time *\*.gcno* files are generated
by the compiler. *\*.gcno* files can be removed with ``make clean``.

After building ctags, you can run run-gcov target.  When running
*\*.gcda* files.  The target runs ctags with all input files under
*Units/\*\*/input.\**; and call ``gcov``. Human readable result is
printed. The detail can be shown in *\*.gcov*. files. *\*.gcda* files
and *\*.gcov* files can be removed with ``make clean-gcov``.

Running cppcheck
------------------------------------------------------------

.. NOT REVIEWED YET

`cppcheck <http://cppcheck.sourceforge.net/>`_ is a tool for static C/C++ code
analysis.

To run it do as following after install cppcheck::

   $ make cppcheck