Add a test suite option to also generate binaries

This commit is contained in:
dcodeIO 2018-11-30 17:51:49 +01:00
parent bf7dd1a64f
commit 5c39043f9e

View File

@ -15,6 +15,12 @@ const config = {
],
"type": "b"
},
"createBinary": {
"description": [
"Also creates the respective .wasm binaries."
],
"type": "b"
},
"help": {
"description": "Prints this message and exits.",
"type": "b",
@ -81,14 +87,17 @@ tests.forEach(filename => {
// TODO: also save stdout/stderr and diff it (-> expected failures)
// Build unoptimized
asc.main([
var cmd = [
filename,
"--baseDir", basedir,
"--validate",
"--measure",
"--debug",
"--textFile" // -> stdout
], {
];
if (args.createBinary)
cmd.push("--binaryFile", basename + ".untouched.wasm");
asc.main(cmd, {
stdout: stdout,
stderr: stderr
}, err => {
@ -141,9 +150,8 @@ tests.forEach(filename => {
"--binaryFile", // -> stdout
"-O3"
];
if (args.create) cmd.push(
"--textFile", basename + ".optimized.wat"
);
if (args.create)
cmd.push("--textFile", basename + ".optimized.wat");
asc.main(cmd, {
stdout: stdout,
stderr: stderr
@ -176,8 +184,11 @@ tests.forEach(filename => {
return parts.join("") + String.fromCharCode.apply(String, U16.subarray(dataOffset, dataOffset + dataRemain));
}
var binaryBuffer = stdout.toBuffer();
if (args.createBinary)
fs.writeFileSync(path.join(basedir, basename + ".optimized.wasm"), binaryBuffer);
let runTime = asc.measure(() => {
exports = new WebAssembly.Instance(new WebAssembly.Module(stdout.toBuffer()), {
exports = new WebAssembly.Instance(new WebAssembly.Module(binaryBuffer), {
env: {
memory,
abort: function(msg, file, line, column) {