-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
30 lines (25 loc) · 805 Bytes
/
test.js
File metadata and controls
30 lines (25 loc) · 805 Bytes
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
const fs = require("fs");
const exec = require("child_process").exec;
function execute(command, callback) {
exec(command, function (error, stdout, stderr) {
callback(stdout);
});
}
fs.readdir("./SampleCode/code", (err, files) => {
if (err) process.exit();
files.forEach((file) => {
const source = `./SampleCode/code/${file}`;
const expect = `./SampleCode/expected/${file.split(".tofu")[0] + ".txt"}`;
const exptxt = fs.readFileSync(expect, "utf8");
execute(`node ./TofuScript.js ${source}`, (output) => {
if (output === exptxt) {
console.log(`Passed test ${source}`);
} else {
console.log(`Failed test ${source}`);
console.log(`exp: ${exptxt}`);
console.log(`got: ${output}`);
process.exit(1);
}
});
});
});