summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-05-15 06:50:32 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-05-15 06:50:32 -0400
commit6f9c919f410c7d97f99515ea99c8dcc434d5d26d (patch)
tree88e3c134c6cafea96ffef304cd370bdb2252df2c
parent5117a8f8a289101723bc74d4e9c45581d5b99172 (diff)
Add test runner
-rw-r--r--Makefile3
-rwxr-xr-xtest.js35
2 files changed, 38 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 78ecb357d..0fa020816 100644
--- a/Makefile
+++ b/Makefile
@@ -45,4 +45,7 @@ fmt: node_modules
go fmt
clang-format msg.proto -i
+test:
+ node test.js
+
.PHONY: lint clean distclean
diff --git a/test.js b/test.js
new file mode 100755
index 000000000..e9ae77755
--- /dev/null
+++ b/test.js
@@ -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()}
+---------------------
+ `);
+ }
+}