Skip to content

Commit 1d19d09

Browse files
EgZvorlpil
authored andcommitted
Test snippet format matches a directory it is in
(see commit cfc7e52) An UltiSnips snippet was added into "snippets" directory which should contain snipmate snippets only. This led to a parsing bug in UltiSnips.
1 parent 0981110 commit 1d19d09

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

tests.sh

+33-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
11
#!/usr/bin/env bash
22

3-
SPACED=$(grep -REn '^ .+' --include '*.snippets' snippets)
4-
5-
if [[ $? -ne 1 ]]; then
6-
echo These snippet lines are indented with spaces:
7-
echo
8-
echo "$SPACED"
9-
echo
10-
echo Tests failed!
3+
check=0
4+
5+
function test_space_indented {
6+
local spaced
7+
spaced=$(grep -REn '^ ' --include '*.snippets' snippets)
8+
9+
if [[ $? -ne 1 ]]; then
10+
echo "These snippet lines are indented with spaces:"
11+
echo "$spaced"
12+
echo
13+
(( check++ ))
14+
fi
15+
}
16+
17+
function test_snipmate_format {
18+
local ultisnips_in_snipmate
19+
ultisnips_in_snipmate=$(grep -REn 'endsnippet' --include '*.snippets' snippets)
20+
if [[ $? -ne 1 ]]; then
21+
echo "These snippet definitions are probably in UltiSnips format but stored in the snipmate directory"
22+
echo "$ultisnips_in_snipmate"
23+
echo
24+
(( check++ ))
25+
fi
26+
}
27+
28+
test_space_indented
29+
test_snipmate_format
30+
31+
if [ $check -eq 0 ]; then
32+
echo "Tests passed!"
33+
exit 0
34+
else
35+
echo "$check test(s) failed out of 2!"
1136
exit 1
1237
fi
13-
14-
echo Tests passed!
15-
exit 0

0 commit comments

Comments
 (0)