-
Notifications
You must be signed in to change notification settings - Fork 29
/
runner.ts
54 lines (40 loc) · 1.53 KB
/
runner.ts
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import * as fs from "fs";
import * as path from "path";
import {execFileSync} from "child_process";
const testFileBasePath = path.join(__dirname, 'snapshots');
const testFiles = [];
fs.readdirSync(testFileBasePath).forEach((directory: string) => {
fs.readdirSync(path.join(testFileBasePath, directory)).forEach((file) => {
if (file.endsWith(".ts")) {
testFiles.push(path.join(testFileBasePath, directory, file));
}
});
});
async function main() {
try {
for (const testFile of testFiles) {
console.log(testFile, "\n");
const compileLog = execFileSync(path.join(__dirname, '..', 'bin', 'ssc'), [
'--printIR',
'--debug',
testFile
]);
console.log(compileLog.toString());
const stdoutExecution = execFileSync(path.join(__dirname, '..', 'output', 'main'));
if (fs.existsSync(path.join(`${testFile}.stdout`))) {
const expectedStdout = fs.readFileSync(path.join(`${testFile}.stdout`));
if (expectedStdout.toString() != stdoutExecution.toString()) {
console.log('Unexpected stdout');
console.log(stdoutExecution.toString());
console.log('Expected stdout');
console.log(expectedStdout.toString());
process.exit(1);
}
}
}
} catch (error) {
console.log(error.output.toString());
process.exit(1);
}
}
main();