Skip to content

Commit 1cdc217

Browse files
committed
test script for schema coverage
1 parent 1951300 commit 1cdc217

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"license": "Apache-2.0",
1515
"scripts": {
1616
"build": "bash ./scripts/md2html/build.sh",
17-
"test": "c8 --100 vitest --watch=false"
17+
"test": "c8 --100 vitest --watch=false && bash scripts/schema-test-coverage.sh"
1818
},
1919
"readmeFilename": "README.md",
2020
"files": [

scripts/schema-test-coverage.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ const allKeywords = keywordLocations(compiled.ast);
9898
const notCovered = allKeywords.filter((location) => !visitedLocations.has(location));
9999
console.log("NOT Covered:", notCovered.length, "of", allKeywords.length,);
100100

101-
const firstNotCovered = notCovered.slice(0, 20);
102-
if (notCovered.length > 20) firstNotCovered.push("...");
101+
const maxNotCovered = 10;
102+
const firstNotCovered = notCovered.slice(0, maxNotCovered);
103+
if (notCovered.length > maxNotCovered) firstNotCovered.push("...");
103104
console.log(firstNotCovered);
104105

105106
console.log("Covered:", visitedLocations.size, "of", allKeywords.length, "(" + Math.floor(visitedLocations.size / allKeywords.length * 100) + "%)");

scripts/schema-test-coverage.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
# Author: @ralfhandl
4+
5+
# Run this script from the root of the repo
6+
7+
echo
8+
echo "Schema Test Coverage"
9+
echo
10+
11+
for schemaDir in schemas/v3* ; do
12+
version=$(basename "$schemaDir")
13+
echo $version
14+
15+
node scripts/schema-test-coverage.mjs $schemaDir/schema.yaml tests/$version
16+
17+
echo
18+
done

0 commit comments

Comments
 (0)