forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
executable file
·35 lines (31 loc) · 972 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
34
35
#!/usr/bin/env node
// Do not include this file from other parts of the code. We use node to
// bootstrap a test runner.
const fs = require("fs");
const path = require("path");
const { execFileSync } = require("child_process");
const testdataDir = path.join(__dirname, "testdata");
const denoFn = path.join(__dirname, "deno");
const files = fs
.readdirSync(testdataDir)
.filter(fn => fn.endsWith(".out"))
.map(fn => path.join(testdataDir, fn));
function deno(inFile) {
let args = [inFile];
console.log("deno", ...args);
return execFileSync(denoFn, args);
}
for (const outFile of files) {
const inFile = outFile.replace(/\.out$/, "");
let stdoutBuffer = deno(inFile);
let outFileBuffer = fs.readFileSync(outFile);
if (0 != Buffer.compare(stdoutBuffer, outFileBuffer)) {
throw Error(`test error
--- stdoutBuffer - ${inFile}
${stdoutBuffer.toString()}
--- outFileBuffer - ${outFile}
${outFileBuffer.toString()}
---------------------
`);
}
}