@@ -15,6 +15,12 @@ const config = {
1515 ] ,
1616 "type" : "b"
1717 } ,
18+ "createBinary" : {
19+ "description" : [
20+ "Also creates the respective .wasm binaries."
21+ ] ,
22+ "type" : "b"
23+ } ,
1824 "help" : {
1925 "description" : "Prints this message and exits." ,
2026 "type" : "b" ,
@@ -81,14 +87,17 @@ tests.forEach(filename => {
8187 // TODO: also save stdout/stderr and diff it (-> expected failures)
8288
8389 // Build unoptimized
84- asc . main ( [
90+ var cmd = [
8591 filename ,
8692 "--baseDir" , basedir ,
8793 "--validate" ,
8894 "--measure" ,
8995 "--debug" ,
9096 "--textFile" // -> stdout
91- ] , {
97+ ] ;
98+ if ( args . createBinary )
99+ cmd . push ( "--binaryFile" , basename + ".untouched.wasm" ) ;
100+ asc . main ( cmd , {
92101 stdout : stdout ,
93102 stderr : stderr
94103 } , err => {
@@ -141,9 +150,8 @@ tests.forEach(filename => {
141150 "--binaryFile" , // -> stdout
142151 "-O3"
143152 ] ;
144- if ( args . create ) cmd . push (
145- "--textFile" , basename + ".optimized.wat"
146- ) ;
153+ if ( args . create )
154+ cmd . push ( "--textFile" , basename + ".optimized.wat" ) ;
147155 asc . main ( cmd , {
148156 stdout : stdout ,
149157 stderr : stderr
@@ -176,8 +184,11 @@ tests.forEach(filename => {
176184 return parts . join ( "" ) + String . fromCharCode . apply ( String , U16 . subarray ( dataOffset , dataOffset + dataRemain ) ) ;
177185 }
178186
187+ var binaryBuffer = stdout . toBuffer ( ) ;
188+ if ( args . createBinary )
189+ fs . writeFileSync ( path . join ( basedir , basename + ".optimized.wasm" ) , binaryBuffer ) ;
179190 let runTime = asc . measure ( ( ) => {
180- exports = new WebAssembly . Instance ( new WebAssembly . Module ( stdout . toBuffer ( ) ) , {
191+ exports = new WebAssembly . Instance ( new WebAssembly . Module ( binaryBuffer ) , {
181192 env : {
182193 memory,
183194 abort : function ( msg , file , line , column ) {
0 commit comments