@@ -592,11 +592,12 @@ def test_cube2hash(self):
592
592
self .do_run ('// empty file' , 'Usage: hashstring <seed>' ,
593
593
libraries = self .get_library ('third_party/cube2hash' , ['libcube2hash.a' ], configure = None ),
594
594
includes = [test_file ('third_party/cube2hash' )], assert_returncode = NON_ZERO )
595
+ js_out = self .output_name ('src' )
595
596
596
597
for text , output in [('fleefl' , '892BDB6FD3F62E863D63DA55851700FDE3ACF30204798CE9' ),
597
598
('fleefl2' , 'AA2CC5F96FC9D540CA24FDAF1F71E2942753DB83E8A81B61' ),
598
599
('64bitisslow' , '64D8470573635EC354FEE7B7F87C566FCAF1EFB491041670' )]:
599
- self .do_run ('src.js' , 'hash value: ' + output , args = [text ], no_build = True )
600
+ self .do_run (js_out , 'hash value: ' + output , args = [text ], no_build = True )
600
601
601
602
@only_wasm2js ('tests 64-bit alignment of structs' )
602
603
def test_align64 (self ):
@@ -1163,46 +1164,48 @@ def test_exceptions_3(self):
1163
1164
}
1164
1165
'''
1165
1166
1167
+ js_out = self .output_name ('src' )
1166
1168
print ('0' )
1167
1169
self .do_run (src , 'Caught C string: a c string\n Done.' , args = ['0' ])
1168
1170
print ('1' )
1169
- self .do_run ('src.js' , 'Caught exception: std::exception\n Done.' , args = ['1' ], no_build = True )
1171
+ self .do_run (js_out , 'Caught exception: std::exception\n Done.' , args = ['1' ], no_build = True )
1170
1172
print ('2' )
1171
- self .do_run ('src.js' , 'Caught exception: Hello\n Done.' , args = ['2' ], no_build = True )
1173
+ self .do_run (js_out , 'Caught exception: Hello\n Done.' , args = ['2' ], no_build = True )
1172
1174
1173
1175
def test_exceptions_allowed (self ):
1174
1176
self .set_setting ('EXCEPTION_CATCHING_ALLOWED' , ["_Z12somefunctionv" ])
1175
1177
# otherwise it is inlined and not identified
1176
1178
self .set_setting ('INLINING_LIMIT' )
1177
1179
1178
1180
self .do_core_test ('test_exceptions_allowed.cpp' )
1179
- size = os .path .getsize ('test_exceptions_allowed.js' )
1181
+ js_out = self .output_name ('test_exceptions_allowed' )
1182
+ size = os .path .getsize (js_out )
1180
1183
if self .is_wasm ():
1181
1184
size += os .path .getsize ('test_exceptions_allowed.wasm' )
1182
- shutil .copy ('test_exceptions_allowed.js' , 'orig.js' )
1185
+ shutil .copy (js_out , 'orig.js' )
1183
1186
1184
1187
# check that an empty allow list works properly (as in, same as exceptions disabled)
1185
1188
1186
1189
self .set_setting ('EXCEPTION_CATCHING_ALLOWED' , [])
1187
1190
self .do_run_in_out_file_test ('core/test_exceptions_allowed.cpp' , out_suffix = '_empty' , assert_returncode = NON_ZERO )
1188
- empty_size = os .path .getsize ('test_exceptions_allowed.js' )
1191
+ empty_size = os .path .getsize (js_out )
1189
1192
if self .is_wasm ():
1190
1193
empty_size += os .path .getsize ('test_exceptions_allowed.wasm' )
1191
- shutil .copy ('test_exceptions_allowed.js' , 'empty.js' )
1194
+ shutil .copy (js_out , 'empty.js' )
1192
1195
1193
1196
self .set_setting ('EXCEPTION_CATCHING_ALLOWED' , ['fake' ])
1194
1197
self .do_run_in_out_file_test ('core/test_exceptions_allowed.cpp' , out_suffix = '_empty' , assert_returncode = NON_ZERO )
1195
- fake_size = os .path .getsize ('test_exceptions_allowed.js' )
1198
+ fake_size = os .path .getsize (js_out )
1196
1199
if self .is_wasm ():
1197
1200
fake_size += os .path .getsize ('test_exceptions_allowed.wasm' )
1198
- shutil .copy ('test_exceptions_allowed.js' , 'fake.js' )
1201
+ shutil .copy (js_out , 'fake.js' )
1199
1202
1200
1203
self .clear_setting ('EXCEPTION_CATCHING_ALLOWED' )
1201
1204
self .do_run_in_out_file_test ('core/test_exceptions_allowed.cpp' , out_suffix = '_empty' , assert_returncode = NON_ZERO )
1202
- disabled_size = os .path .getsize ('test_exceptions_allowed.js' )
1205
+ disabled_size = os .path .getsize (js_out )
1203
1206
if self .is_wasm ():
1204
1207
disabled_size += os .path .getsize ('test_exceptions_allowed.wasm' )
1205
- shutil .copy ('test_exceptions_allowed.js' , 'disabled.js' )
1208
+ shutil .copy (js_out , 'disabled.js' )
1206
1209
1207
1210
print ('size: %d' % size )
1208
1211
print ('empty_size: %d' % empty_size )
@@ -1965,8 +1968,8 @@ def test_em_js(self, args, force_c):
1965
1968
if '-pthread' in args :
1966
1969
self .setup_node_pthreads ()
1967
1970
1968
- self .do_core_test ('test_em_js.cpp' , force_c = force_c )
1969
- self .assertContained (" no args returning int" , read_file ('test_em_js.js' ))
1971
+ err = self .do_core_test ('test_em_js.cpp' , force_c = force_c )
1972
+ self .assertContained (' no args returning int' , read_file (self . output_name ( 'test_em_js' ) ))
1970
1973
1971
1974
@no_wasm2js ('test depends on WASM_BIGINT which is not compatible with wasm2js' )
1972
1975
def test_em_js_i64 (self ):
@@ -2013,12 +2016,12 @@ def test_memorygrowth(self):
2013
2016
2014
2017
# Fail without memory growth
2015
2018
self .do_runf (src , 'OOM' , assert_returncode = NON_ZERO )
2016
- fail = read_file ('test_memorygrowth.js' )
2019
+ fail = read_file (self . output_name ( 'test_memorygrowth' ) )
2017
2020
2018
2021
# Win with it
2019
2022
self .set_setting ('ALLOW_MEMORY_GROWTH' )
2020
2023
self .do_runf (src , '*pre: hello,4.955*\n *hello,4.955*\n *hello,4.955*' )
2021
- win = read_file ('test_memorygrowth.js' )
2024
+ win = read_file (self . output_name ( 'test_memorygrowth' ) )
2022
2025
2023
2026
if '-O2' in self .emcc_args and self .is_wasm2js ():
2024
2027
# Make sure ALLOW_MEMORY_GROWTH generates different code (should be less optimized)
@@ -2046,12 +2049,12 @@ def test_memorygrowth_2(self):
2046
2049
2047
2050
# Fail without memory growth
2048
2051
self .do_runf (src , 'OOM' , assert_returncode = NON_ZERO )
2049
- fail = read_file ('test_memorygrowth_2.js' )
2052
+ fail = read_file (self . output_name ( 'test_memorygrowth_2' ) )
2050
2053
2051
2054
# Win with it
2052
2055
self .set_setting ('ALLOW_MEMORY_GROWTH' )
2053
2056
self .do_runf (src , '*pre: hello,4.955*\n *hello,4.955*\n *hello,4.955*' )
2054
- win = read_file ('test_memorygrowth_2.js' )
2057
+ win = read_file (self . output_name ( 'test_memorygrowth_2' ) )
2055
2058
2056
2059
if '-O2' in self .emcc_args and self .is_wasm2js ():
2057
2060
# Make sure ALLOW_MEMORY_GROWTH generates different code (should be less optimized)
@@ -2110,7 +2113,7 @@ def test_memorygrowth_3_force_fail_reallocBuffer(self):
2110
2113
self .set_setting ('ALLOW_MEMORY_GROWTH' )
2111
2114
# Force memory growth to fail at runtime
2112
2115
self .add_pre_run ('growMemory = (size) => false;' )
2113
- self .do_core_test ('test_memorygrowth_3.c' )
2116
+ self .do_core_test ('test_memorygrowth_3.c' , emcc_args = [ '-sINCOMING_MODULE_JS_API=preRun' ] )
2114
2117
2115
2118
@parameterized ({
2116
2119
'nogrow' : ([],),
@@ -5561,7 +5564,7 @@ def test_readdir_unlink(self):
5561
5564
def test_stat (self ):
5562
5565
self .set_setting ("FORCE_FILESYSTEM" )
5563
5566
self .do_runf ('stat/test_stat.c' , 'success' )
5564
- self .verify_in_strict_mode ('test_stat.js' )
5567
+ self .verify_in_strict_mode (self . output_name ( 'test_stat' ) )
5565
5568
5566
5569
def test_statx (self ):
5567
5570
self .set_setting ("FORCE_FILESYSTEM" )
@@ -6157,6 +6160,7 @@ def test_iostream_and_determinism(self):
6157
6160
return 0;
6158
6161
}
6159
6162
''' )
6163
+ js_out = self .output_name ('src' )
6160
6164
6161
6165
num = 5
6162
6166
for i in range (num ):
@@ -6168,8 +6172,8 @@ def test_iostream_and_determinism(self):
6168
6172
6169
6173
# Verify that this build is identical to the previous one
6170
6174
if os .path .exists ('src.js.previous' ):
6171
- self .assertBinaryEqual ('src.js' , 'src.js.previous' )
6172
- shutil .copy2 ('src.js' , 'src.js.previous' )
6175
+ self .assertBinaryEqual (js_out , 'src.js.previous' )
6176
+ shutil .copy2 (js_out , 'src.js.previous' )
6173
6177
6174
6178
# Same but for the wasm file.
6175
6179
if self .is_wasm ():
@@ -6272,10 +6276,10 @@ def test_constglobalunion(self):
6272
6276
6273
6277
def test_fannkuch (self ):
6274
6278
results = [(1 , 0 ), (2 , 1 ), (3 , 2 ), (4 , 4 ), (5 , 7 ), (6 , 10 ), (7 , 16 ), (8 , 22 )]
6275
- self .build ('third_party/fannkuch.c' )
6279
+ js_out = self .build ('third_party/fannkuch.c' )
6276
6280
for i , j in results :
6277
6281
print (i , j )
6278
- self .do_run ('fannkuch.js' , 'Pfannkuchen(%d) = %d.' % (i , j ), args = [str (i )], no_build = True )
6282
+ self .do_run (js_out , 'Pfannkuchen(%d) = %d.' % (i , j ), args = [str (i )], no_build = True )
6279
6283
6280
6284
def test_raytrace (self ):
6281
6285
# TODO: Should we remove this test?
@@ -6298,9 +6302,9 @@ def test_fasta(self, float_type):
6298
6302
6299
6303
src = orig_src .replace ('double' , float_type )
6300
6304
create_file ('fasta.cpp' , src )
6301
- self .build ('fasta.cpp' )
6305
+ js_out = self .build ('fasta.cpp' )
6302
6306
for arg , output in results :
6303
- self .do_run ('fasta.js' , output , args = [arg ], no_build = True )
6307
+ self .do_run (js_out , output , args = [arg ], no_build = True )
6304
6308
6305
6309
@needs_non_trapping_float_to_int
6306
6310
def test_fasta_nontrapping (self ):
@@ -7658,17 +7662,12 @@ def test_embind_sync_if_pthread_delayed(self):
7658
7662
### Tests for tools
7659
7663
7660
7664
@no_wasm2js ('TODO: source maps in wasm2js' )
7661
- @parameterized ({
7662
- '' : ([],),
7663
- 'minimal_runtime' : (['-sMINIMAL_RUNTIME' ],),
7664
- })
7665
+ @also_with_minimal_runtime
7665
7666
@requires_node
7666
- def test_source_map (self , args ):
7667
+ def test_source_map (self ):
7667
7668
if '-g' not in self .emcc_args :
7668
7669
self .emcc_args .append ('-g' )
7669
7670
7670
- self .emcc_args += args
7671
-
7672
7671
src = '''
7673
7672
#include <stdio.h>
7674
7673
#include <assert.h>
@@ -7685,7 +7684,7 @@ def test_source_map(self, args):
7685
7684
'''
7686
7685
create_file ('src.cpp' , src )
7687
7686
7688
- out_filename = 'a.out.js'
7687
+ out_filename = self . output_name ( 'a.out' )
7689
7688
wasm_filename = 'a.out.wasm'
7690
7689
no_maps_filename = 'no-maps.out.js'
7691
7690
@@ -7769,13 +7768,11 @@ def test_embind_dylink_visibility_hidden(self):
7769
7768
def test_dwarf (self ):
7770
7769
self .emcc_args .append ('-g' )
7771
7770
7772
- js_filename = 'a.out.js'
7773
- wasm_filename = 'a.out.wasm'
7774
7771
shutil .copy (test_file ('core/test_dwarf.c' ), '.' )
7775
7772
7776
- self .emcc ('test_dwarf.c' , output_filename = js_filename )
7773
+ self .emcc ('test_dwarf.c' )
7777
7774
7778
- out = self .run_process ([shared .LLVM_DWARFDUMP , wasm_filename , '-all' ], stdout = PIPE ).stdout
7775
+ out = self .run_process ([shared .LLVM_DWARFDUMP , 'a.out.wasm' , '-all' ], stdout = PIPE ).stdout
7779
7776
7780
7777
# parse the sections
7781
7778
sections = {}
@@ -7845,7 +7842,7 @@ def get_dwarf_addr(line, col):
7845
7842
7846
7843
# Get the wat, printing with -g which has binary offsets
7847
7844
wat = self .run_process ([os .path .join (building .get_binaryen_bin (), 'wasm-opt' ),
7848
- wasm_filename , '-g' , '--print' , '-all' ], stdout = PIPE ).stdout
7845
+ 'a.out.wasm' , '-g' , '--print' , '-all' ], stdout = PIPE ).stdout
7849
7846
7850
7847
# We expect to see a pattern like this in optimized builds (there isn't
7851
7848
# much that can change with such calls to JS (they can't be reordered or
@@ -8589,7 +8586,7 @@ def test_environment(self):
8589
8586
8590
8587
def test (assert_returncode = 0 ):
8591
8588
self .do_core_test ('test_hello_world.c' , assert_returncode = assert_returncode )
8592
- js = read_file ('test_hello_world.js' )
8589
+ js = read_file (self . output_name ( 'test_hello_world' ) )
8593
8590
assert ('require(' in js ) == ('node' in self .get_setting ('ENVIRONMENT' )), 'we should have require() calls only if node js specified'
8594
8591
8595
8592
for engine in config .JS_ENGINES :
@@ -8625,8 +8622,8 @@ def test_postrun_exception(self):
8625
8622
# verify that an exception thrown in postRun() will not trigger the
8626
8623
# compilation failed handler, and will be printed to stderr.
8627
8624
self .add_post_run ('ThisFunctionDoesNotExist()' )
8628
- self .build ('core/test_hello_world.c' )
8629
- output = self .run_js ('test_hello_world.js' , assert_returncode = NON_ZERO )
8625
+ out_js = self .build ('core/test_hello_world.c' )
8626
+ output = self .run_js (out_js , assert_returncode = NON_ZERO )
8630
8627
self .assertStartswith (output , 'hello, world!' )
8631
8628
self .assertContained ('ThisFunctionDoesNotExist is not defined' , output )
8632
8629
0 commit comments