mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-03 01:51:38 +00:00
Add a test suite option to also generate binaries
This commit is contained in:
parent
bf7dd1a64f
commit
5c39043f9e
@ -15,6 +15,12 @@ const config = {
|
|||||||
],
|
],
|
||||||
"type": "b"
|
"type": "b"
|
||||||
},
|
},
|
||||||
|
"createBinary": {
|
||||||
|
"description": [
|
||||||
|
"Also creates the respective .wasm binaries."
|
||||||
|
],
|
||||||
|
"type": "b"
|
||||||
|
},
|
||||||
"help": {
|
"help": {
|
||||||
"description": "Prints this message and exits.",
|
"description": "Prints this message and exits.",
|
||||||
"type": "b",
|
"type": "b",
|
||||||
@ -81,14 +87,17 @@ tests.forEach(filename => {
|
|||||||
// TODO: also save stdout/stderr and diff it (-> expected failures)
|
// TODO: also save stdout/stderr and diff it (-> expected failures)
|
||||||
|
|
||||||
// Build unoptimized
|
// Build unoptimized
|
||||||
asc.main([
|
var cmd = [
|
||||||
filename,
|
filename,
|
||||||
"--baseDir", basedir,
|
"--baseDir", basedir,
|
||||||
"--validate",
|
"--validate",
|
||||||
"--measure",
|
"--measure",
|
||||||
"--debug",
|
"--debug",
|
||||||
"--textFile" // -> stdout
|
"--textFile" // -> stdout
|
||||||
], {
|
];
|
||||||
|
if (args.createBinary)
|
||||||
|
cmd.push("--binaryFile", basename + ".untouched.wasm");
|
||||||
|
asc.main(cmd, {
|
||||||
stdout: stdout,
|
stdout: stdout,
|
||||||
stderr: stderr
|
stderr: stderr
|
||||||
}, err => {
|
}, err => {
|
||||||
@ -141,9 +150,8 @@ tests.forEach(filename => {
|
|||||||
"--binaryFile", // -> stdout
|
"--binaryFile", // -> stdout
|
||||||
"-O3"
|
"-O3"
|
||||||
];
|
];
|
||||||
if (args.create) cmd.push(
|
if (args.create)
|
||||||
"--textFile", basename + ".optimized.wat"
|
cmd.push("--textFile", basename + ".optimized.wat");
|
||||||
);
|
|
||||||
asc.main(cmd, {
|
asc.main(cmd, {
|
||||||
stdout: stdout,
|
stdout: stdout,
|
||||||
stderr: stderr
|
stderr: stderr
|
||||||
@ -176,8 +184,11 @@ tests.forEach(filename => {
|
|||||||
return parts.join("") + String.fromCharCode.apply(String, U16.subarray(dataOffset, dataOffset + dataRemain));
|
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(() => {
|
let runTime = asc.measure(() => {
|
||||||
exports = new WebAssembly.Instance(new WebAssembly.Module(stdout.toBuffer()), {
|
exports = new WebAssembly.Instance(new WebAssembly.Module(binaryBuffer), {
|
||||||
env: {
|
env: {
|
||||||
memory,
|
memory,
|
||||||
abort: function(msg, file, line, column) {
|
abort: function(msg, file, line, column) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user