-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add playground config validation script and CI (#1976)
* Add playground config validation script and CI Signed-off-by: Yashodhan Joshi <[email protected]> * Fix the validation script to consider all passes Also removes the invalid examples and passes Signed-off-by: Yashodhan Joshi <[email protected]> --------- Signed-off-by: Yashodhan Joshi <[email protected]> Co-authored-by: Rachit Nigam <[email protected]>
- Loading branch information
1 parent
e89ed24
commit 1632dfd
Showing
4 changed files
with
68 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const childProcess = require("child_process"); | ||
const config = require("./data/config.json"); | ||
const passes = require("./data/passes.json").passes.map((p) => p.name); | ||
const examples = config.examples; | ||
|
||
// we assume that we have a debug build of calyx ready | ||
const _spawned = childProcess.spawnSync( | ||
path.join(__dirname, "..", "target/debug/calyx"), | ||
["pass-help"], | ||
); | ||
const op = new String(_spawned.stdout); | ||
const passList = op.split("Aliases:\n")[0]; | ||
const allPasses = passList | ||
.split("\n") | ||
.filter((s) => s.startsWith("-")) // each pass in the list starts with - , eg: - tdcc: something-about-tdcc | ||
.map((s)=>s.split(":")[0]) // split by : to get the pass name and skip desc, eg : - tdcc | ||
.map((s)=>s.replace("-","").trim()) // replcae the initial - and trim. Note this will not replace - from pass names, only the leading one | ||
.join(","); | ||
|
||
const errors = []; | ||
|
||
for (const pass of passes) { | ||
if (!allPasses.includes(pass)) { | ||
errors.push(`pass ${pass} is not valid`); | ||
} | ||
} | ||
|
||
const validPasses = passes.filter((p) => allPasses.includes(p)); | ||
|
||
for (const eg of examples) { | ||
const filepath = path.join(__dirname, "..", eg.file); | ||
if (!fs.existsSync(filepath)) { | ||
errors.push(`file ${eg.file} does not exist`); | ||
} | ||
for (const pass of eg.passes) { | ||
if (!validPasses.includes(pass)) { | ||
errors.push(`pass ${pass} for example ${eg.name} is invalid`); | ||
} | ||
} | ||
} | ||
if (errors.length > 0) { | ||
console.error(errors); | ||
process.exit(1); | ||
} |