Skip to content

Commit

Permalink
Merge pull request #139 from near/js_errors
Browse files Browse the repository at this point in the history
Improve error messages when running tests from commandline
  • Loading branch information
aborg-dev authored Dec 4, 2023
2 parents a343b5f + a72ad8e commit 21e897e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions tests/zkasm/run-tests-zkasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ const emptyInput = require('@0xpolygonhermez/zkevm-proverjs/test/inputs/empty_in
const pathMainPil = path.join(__dirname, 'node_modules/@0xpolygonhermez/zkevm-proverjs/pil/main.pil');
const fileCachePil = path.join(__dirname, 'node_modules/@0xpolygonhermez/zkevm-proverjs/cache-main-pil.json');

function value_to_json(key, value) {
if (typeof value === "bigint") {
return value.toString();
}

// Serialize exceptions by inlining all referenced fields.
if (value instanceof Error) {
return JSON.stringify(value, Object.getOwnPropertyNames(value));
}

return value;
}

async function main() {
// Compile pil
const cmPols = await compilePil();
Expand All @@ -34,13 +47,11 @@ async function main() {
testResults.push(await runTest(file, cmPols));
}

const json = JSON.stringify(testResults, (key, value) =>
typeof value === "bigint" ? value.toString() : value
);
if (process.argv[3]) {
const json = JSON.stringify(testResults, value_to_json);
fs.writeFileSync(process.argv[3], json);
} else {
console.log(json);
console.log(testResults);
}
}

Expand Down Expand Up @@ -112,9 +123,9 @@ async function runTest(pathTest, cmPols) {
return {
path: pathTest,
status: "runtime error",
error: JSON.stringify(e, Object.getOwnPropertyNames(e)),
error: e,
}
}
}

main();
main();

0 comments on commit 21e897e

Please sign in to comment.