-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
33 lines (23 loc) · 839 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"use strict";
const glob = require("glob");
const path = require("path");
const executor = require("./executor");
const jsonFiles = glob.sync("./handled-tasks/**/*.json");
const errors = [];
for (const file of jsonFiles) {
const folder = path.dirname(file);
const { train, test } = require(file);
for (const [i, testGrid] of test.entries()) {
const grid = testGrid.input;
const output = executor(path.join(folder, "program.js"), grid);
if (JSON.stringify(output) !== JSON.stringify(testGrid.output)) {
errors.push(`Failed test grid #${i + 1} of task "${file}"`);
} else {
console.log(`Successfully solved test grid #${i + 1} of task "${file}"`)
}
}
}
if (errors.length > 0) {
console.error(JSON.stringify(errors, null, 2));
throw new Error("Some tests failed. More details above.");
}