Skip to content

Commit

Permalink
fix: fix asc compilation for the tests
Browse files Browse the repository at this point in the history
- Use stdout/stderr and check the returned error
- use outFile instead of binaryFile
- remove wasm file if it exists
  • Loading branch information
aminya committed Jan 21, 2024
1 parent 4360a21 commit 0cb2cad
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions test/test-runner.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from "fs/promises";
import fsSync from "fs";
import { dirname, join } from "path";
import { createRequire } from "module";

Expand Down Expand Up @@ -43,18 +44,32 @@ async function compileAllAsc() {
Object.assign(config, m);
} catch (e) {}
console.log(`Compiling ${ascFile}...`);

const wasmFile = ascFile.replace(/\.ts$/, ".wasm");
if (fsSync.existsSync(wasmFile)) {
await fs.unlink(wasmFile);
}

const params = [
"--runtime",
"stub",
"--exportRuntime",
"--transform",
transformFile,
"--binaryFile",
"--outFile",
ascFile.replace(/\.ts$/, ".wasm"),
ascFile
];
config.mangleCompilerParams(params);
await asc.main(params);
const result = await asc.main(params, {
stderr: process.stderr,
stdout: process.stdout
});

if (result.error !== null) {
console.error(`Failed to compile ${ascFile}`);
process.exit(1);
}
}
}

Expand Down

0 comments on commit 0cb2cad

Please sign in to comment.