forked from haskell/unix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-wasm32-wasi.mjs
executable file
·35 lines (30 loc) · 1.01 KB
/
test-wasm32-wasi.mjs
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
import child_process from "child_process";
import fs from "fs";
import util from "util";
const my_execFile = util.promisify(child_process.execFile);
let warns_count = 0;
for (const f of await fs.promises.readdir("tests")) {
// odd linker errors
if (f.startsWith('Semaphore')) continue;
// Find self-contained test cases (aka doesn't rely on tasty)
if (!f.endsWith(".hs")) continue;
const s = await fs.promises.readFile(`tests/${f}`, "utf-8");
if (s.indexOf("Test.Tasty") !== -1) continue;
// Compile the test case
console.log(`\n${f}`);
const r = await my_execFile("wasm32-wasi-ghc", [
`tests/${f}`,
"-Wno-deprecations",
"-optl-Wl,--warn-unresolved-symbols",
]);
// Check for wasm-ld warnings that involves the archive generated by
// cabal build
const warns = r.stderr
.split("\n")
.filter((l) => l.indexOf("dist-newstyle") !== -1);
warns_count += warns.length;
console.log(warns);
}
// Use exit code to indicate failure
process.exit(warns_count === 0 ? 0 : 1);