mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
Add test runner
This commit is contained in:
parent
5117a8f8a2
commit
6f9c919f41
2 changed files with 38 additions and 0 deletions
3
Makefile
3
Makefile
|
@ -45,4 +45,7 @@ fmt: node_modules
|
|||
go fmt
|
||||
clang-format msg.proto -i
|
||||
|
||||
test:
|
||||
node test.js
|
||||
|
||||
.PHONY: lint clean distclean
|
||||
|
|
35
test.js
Executable file
35
test.js
Executable file
|
@ -0,0 +1,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()}
|
||||
---------------------
|
||||
`);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue