@@ -7394,24 +7394,32 @@ def test_binaryen_ctors(self):
7394
7394
seen = run_js ('b.out.js' , engine = SPIDERMONKEY_ENGINE )
7395
7395
assert correct == seen , correct + '\n vs \n ' + seen
7396
7396
7397
- def test_binaryen_debuginfo ( self ):
7398
- with clean_write_access_to_canonical_temp_dir ( ):
7397
+ # test debug info and debuggability of JS output
7398
+ def test_binaryen_debug ( self ):
7399
7399
if os .environ .get ('EMCC_DEBUG' ): return self .skip ('cannot run in debug mode' )
7400
7400
try :
7401
7401
os .environ ['EMCC_DEBUG' ] = '1'
7402
- for args , expect_dash_g , expect_emit_text in [
7403
- (['-O0' ], False , False ),
7404
- (['-O0' , '-g1' ], False , False ),
7405
- (['-O0' , '-g2' ], True , False ), # in -g2+, we emit -g to asm2wasm so function names are saved
7406
- (['-O0' , '-g' ], True , True ),
7407
- (['-O0' , '--profiling-funcs' ], True , False ),
7408
- (['-O1' ], False , False ),
7402
+ for args , expect_dash_g , expect_emit_text , expect_clean_js , expect_whitespace_js , expect_closured in [
7403
+ (['-O0' ], False , False , False , True , False ),
7404
+ (['-O0' , '-g1' ], False , False , False , True , False ),
7405
+ (['-O0' , '-g2' ], True , False , False , True , False ), # in -g2+, we emit -g to asm2wasm so function names are saved
7406
+ (['-O0' , '-g' ], True , True , False , True , False ),
7407
+ (['-O0' , '--profiling-funcs' ], True , False , False , True , False ),
7408
+ (['-O1' ], False , False , False , True , False ),
7409
+ (['-O2' ], False , False , True , False , False ),
7410
+ (['-O2' , '-g1' ], False , False , True , True , False ),
7411
+ (['-O2' , '-g' ], True , True , False , True , False ),
7412
+ (['-O2' , '--closure' , '1' ], False , False , True , False , True ),
7413
+ (['-O2' , '--closure' , '1' , '-g1' ], False , False , True , True , True ),
7414
+ (['-O2' , '--js-opts' , '1' ], False , False , True , False , False ),
7409
7415
]:
7410
7416
print args , expect_dash_g , expect_emit_text
7411
7417
try_delete ('a.out.wast' )
7412
7418
cmd = [PYTHON , EMCC , path_from_root ('tests' , 'hello_world.cpp' ), '-s' , 'WASM=1' ] + args
7413
7419
print ' ' .join (cmd )
7414
- output , err = Popen (cmd , stdout = PIPE , stderr = PIPE ).communicate ()
7420
+ proc = Popen (cmd , stdout = PIPE , stderr = PIPE )
7421
+ output , err = proc .communicate ()
7422
+ assert proc .returncode == 0
7415
7423
asm2wasm_line = filter (lambda x : 'asm2wasm' in x , err .split ('\n ' ))[0 ]
7416
7424
asm2wasm_line = asm2wasm_line .strip () + ' ' # ensure it ends with a space, for simpler searches below
7417
7425
print '|' + asm2wasm_line + '|'
@@ -7421,6 +7429,10 @@ def test_binaryen_debuginfo(self):
7421
7429
text = open ('a.out.wast' ).read ()
7422
7430
assert ';;' in text , 'must see debug info comment'
7423
7431
assert 'hello_world.cpp:6' in text , 'must be file:line info'
7432
+ js = open ('a.out.js' ).read ()
7433
+ assert expect_clean_js == ('// ' not in js ), 'cleaned-up js must not have comments'
7434
+ assert expect_whitespace_js == ('{\n ' in js ), 'whitespace-minified js must not have excess spacing'
7435
+ assert expect_closured == ('var a;' in js ), 'closured js must have tiny variable names'
7424
7436
finally :
7425
7437
del os .environ ['EMCC_DEBUG' ]
7426
7438
0 commit comments