Skip to content

Commit 7ddafeb

Browse files
committed
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 a742d86 commit 7ddafeb

File tree

3 files changed

+37
-17
lines changed

3 files changed

+37
-17
lines changed

UltiSnips/python.snippets

+4-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ write_init_body(args, t[2], snip)
278278
$0
279279
endsnippet
280280

281-
282281
snippet slotclass "class with slots and docstrings" b
283282
class ${1:MyClass}(${2:object}):
284283

@@ -664,6 +663,10 @@ snippet ann "Assert is not None" b
664663
self.assertIsNotNone(${1:${VISUAL:expression}})
665664
endsnippet
666665

666+
snippet sk "skip unittests" b
667+
@unittest.skip(${1:skip_reason})
668+
endsnippet
669+
667670
snippet testcase "pyunit testcase" b
668671
class Test${1:Class}(${2:unittest.TestCase}):
669672

snippets/python.snippets

-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ snippet docs
2222
Description: ${0}
2323
"""
2424

25-
# Unittest skip
26-
snippet sk "skip unittests" b
27-
@unittest.skip(${1:skip_reason})
28-
endsnippet
29-
3025
snippet wh
3126
while ${1:condition}:
3227
${0:${VISUAL}}

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)