Skip to content

Commit

Permalink
test script for schema coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfhandl committed Nov 1, 2024
1 parent 1951300 commit 1cdc217
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"license": "Apache-2.0",
"scripts": {
"build": "bash ./scripts/md2html/build.sh",
"test": "c8 --100 vitest --watch=false"
"test": "c8 --100 vitest --watch=false && bash scripts/schema-test-coverage.sh"
},
"readmeFilename": "README.md",
"files": [
Expand Down
5 changes: 3 additions & 2 deletions scripts/schema-test-coverage.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ const allKeywords = keywordLocations(compiled.ast);
const notCovered = allKeywords.filter((location) => !visitedLocations.has(location));
console.log("NOT Covered:", notCovered.length, "of", allKeywords.length,);

const firstNotCovered = notCovered.slice(0, 20);
if (notCovered.length > 20) firstNotCovered.push("...");
const maxNotCovered = 10;
const firstNotCovered = notCovered.slice(0, maxNotCovered);
if (notCovered.length > maxNotCovered) firstNotCovered.push("...");
console.log(firstNotCovered);

console.log("Covered:", visitedLocations.size, "of", allKeywords.length, "(" + Math.floor(visitedLocations.size / allKeywords.length * 100) + "%)");
18 changes: 18 additions & 0 deletions scripts/schema-test-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

# Author: @ralfhandl

# Run this script from the root of the repo

echo
echo "Schema Test Coverage"
echo

for schemaDir in schemas/v3* ; do
version=$(basename "$schemaDir")
echo $version

node scripts/schema-test-coverage.mjs $schemaDir/schema.yaml tests/$version

echo
done

0 comments on commit 1cdc217

Please sign in to comment.