-
Notifications
You must be signed in to change notification settings - Fork 5
/
test_ctags
executable file
·73 lines (62 loc) · 1.46 KB
/
test_ctags
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
#!/usr/bin/env bash
# Test the installed universal_ctags
set -e # exit on error
# set -x # debug output
ctags="/snap/bin/ctags"
config_dir="$HOME/.ctags.d"
config="${config_dir}/python.ctags"
backup="${config_dir}.backup"
output="sample/tags"
red='\e[1;31m'
green='\e[1;32m'
reset='\e[0m'
# Given the original config dir is backed up
if [ -d ${config_dir} ] ; then
rm -rf ${backup}
mv ${config_dir} ${backup}
else
rm -rf ${backup}
fi
# and it'll get restored when this scenario ends
function clean {
if [ -d ${backup} ] ; then
rm -rf ${config_dir}
mv ${backup} ${config_dir}
else
rm -rf ${config_dir}
fi
}
trap clean EXIT
# and the new config turns off Classes in the output
mkdir -p ${config_dir}
echo "--python-kinds=-c" >${config}
# When we run ctags on some sample source code
(
cd sample
${ctags} -R .
)
# Then the output file should contain func 'my_func'
if ! grep -q -E '^my_func' ${output} ; then
echo
echo -e "${red}FAIL${reset}: '${output}' should contain function 'my_func'" >&2
echo
echo "${output}:"
cat ${output}
echo
exit 1
fi
# and should not contain class 'MyClass'
# (disabled by user-level config in ${config} above)
if grep -q -E '^MyClass' ${output} ; then
echo
echo -e "${red}FAIL${reset}: '${output}' should not contain class 'MyClass'" >&2
echo
echo "${config}:"
cat ${config}
echo
echo "${output}:"
cat ${output}
echo
exit 1
fi
echo -e "${green}OK${reset}" >&2