Skip to content

Commit e4dd8cb

Browse files
committed
test: Add test to ensure all keyword nodes are highlighted
1 parent 07e6245 commit e4dd8cb

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
node-version: 18
2222
- run: npm install
2323
- run: npm test
24+
- run: scripts/test-keywords.sh
2425
validate_tests:
2526
runs-on: ["ubuntu-latest"]
2627
strategy:

scripts/test-keywords.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
mkdir -p tmp/tree-sitter-sql/
4+
5+
cat src/grammar.json |
6+
jq '.rules | to_entries[] | select(.key | contains("keyword")) | .key' |
7+
tr -d '"' |
8+
sort > tmp/tree-sitter-sql/keywords.txt
9+
10+
cat queries/highlights.scm |
11+
grep -o "keyword\w\+" |
12+
sort > tmp/tree-sitter-sql/highlights.txt
13+
14+
keywords=$(comm -3 tmp/tree-sitter-sql/keywords.txt tmp/tree-sitter-sql/highlights.txt)
15+
16+
if [[ "$keywords" ]]; then
17+
echo "ERROR: keywords in grammar.json are not in sync with queries/highlights.scm"
18+
echo $keywords
19+
exit 1
20+
fi

0 commit comments

Comments
 (0)