@@ -702,8 +702,7 @@ def test_preprocessed_input(self):
702
702
#endif
703
703
int main() { puts("hello"); }
704
704
''' )
705
- self .run_process ([EMCC , 'simple' + suffix ])
706
- self .assertContained ('hello' , self .run_js ('a.out.js' ))
705
+ self .do_runf ('simple' + suffix , 'hello' )
707
706
708
707
create_test_file ('with_include' + suffix , '#include <stdio.h>\n int main() { puts("hello"); }' )
709
708
err = self .expect_fail ([EMCC , 'with_include' + suffix ])
@@ -3770,12 +3769,9 @@ def test_stat_silly(self):
3770
3769
}
3771
3770
}
3772
3771
''' )
3773
- self .run_process ([EMCC , 'src.cpp' ])
3774
-
3775
- # cannot stat ""
3776
- self .assertContained (r'''Failed to stat path: /a; errno=44
3772
+ self .do_runf ('src.cpp' , r'''Failed to stat path: /a; errno=44
3777
3773
Failed to stat path: ; errno=44
3778
- ''' , self . run_js ( 'a.out.js' , args = ['/a' , '' ]) )
3774
+ ''' , args = ['/a' , '' ])
3779
3775
3780
3776
def test_symlink_silly (self ):
3781
3777
create_test_file ('src.cpp' , r'''
@@ -3936,10 +3932,8 @@ def test_readdir_r_silly(self):
3936
3932
return 0;
3937
3933
}
3938
3934
''' )
3939
- self .run_process ([EMCC , 'src.cpp' ])
3940
-
3941
3935
# cannot symlink nonexistents
3942
- self .assertContained ( r'''Before:
3936
+ self .do_runf ( 'src.cpp' , r'''Before:
3943
3937
dir
3944
3938
a
3945
3939
b
@@ -3954,7 +3948,7 @@ def test_readdir_r_silly(self):
3954
3948
Unlinking e
3955
3949
After:
3956
3950
dir
3957
- ''' , self . run_js ( 'a.out.js' , args = ['' , 'abc' ]) )
3951
+ ''' , args = ['' , 'abc' ])
3958
3952
3959
3953
def test_emversion (self ):
3960
3954
create_test_file ('src.cpp' , r'''
@@ -4287,8 +4281,7 @@ def test_strftime_zZ(self):
4287
4281
self .assertContained ('ok!' , self .run_js ('a.out.js' ))
4288
4282
4289
4283
def test_strptime_symmetry (self ):
4290
- building .emcc (path_from_root ('tests' , 'strptime_symmetry.cpp' ), output_filename = 'a.out.js' )
4291
- self .assertContained ('TEST PASSED' , self .run_js ('a.out.js' ))
4284
+ self .do_runf (path_from_root ('tests' , 'strptime_symmetry.cpp' ), 'TEST PASSED' )
4292
4285
4293
4286
def test_truncate_from_0 (self ):
4294
4287
create_test_file ('src.cpp' , r'''
@@ -4393,8 +4386,7 @@ def test_truncate_from_0(self):
4393
4386
return 0;
4394
4387
}
4395
4388
''' )
4396
- self .run_process ([EMCC , 'src.cpp' ])
4397
- self .assertContained (r'''Creating file: /tmp/file with content=This is some content
4389
+ self .do_runf ('src.cpp' , r'''Creating file: /tmp/file with content=This is some content
4398
4390
Size of file is: 20
4399
4391
Truncating file=/tmp/file to length=32
4400
4392
Size of file is: 32
@@ -4404,7 +4396,7 @@ def test_truncate_from_0(self):
4404
4396
Size of file is: 0
4405
4397
Truncating file=/tmp/file to length=32
4406
4398
Size of file is: 32
4407
- ''' , self . run_js ( 'a.out.js' ) )
4399
+ ''' )
4408
4400
4409
4401
def test_create_readonly (self ):
4410
4402
create_test_file ('src.cpp' , r'''
@@ -4475,12 +4467,11 @@ def test_create_readonly(self):
4475
4467
"exists and is read-only.\n\n");
4476
4468
}
4477
4469
''' )
4478
- self .run_process ([EMCC , 'src.cpp' ])
4479
- self .assertContained (r'''Creating file: /tmp/file with content of size=292
4470
+ self .do_runf ('src.cpp' , r'''Creating file: /tmp/file with content of size=292
4480
4471
Data written to file=/tmp/file; successfully wrote 292 bytes
4481
4472
Creating file: /tmp/file with content of size=79
4482
4473
Failed to open file for writing: /tmp/file; errno=2; Permission denied
4483
- ''' , self . run_js ( 'a.out.js' ) )
4474
+ ''' )
4484
4475
4485
4476
def test_embed_file_large (self ):
4486
4477
# If such long files are encoded on one line,
@@ -4569,9 +4560,8 @@ def test_browser_language_detection(self):
4569
4560
# Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.5,en;q=0.3
4570
4561
create_test_file ('preamble.js' , r'''navigator = {};
4571
4562
navigator.languages = [ "fr-FR", "fr", "en-US", "en" ];''' )
4572
- self .run_process ([EMCC , '--pre-js' , 'preamble.js' ,
4573
- path_from_root ('tests' , 'test_browser_language_detection.c' )])
4574
- self .assertContained ('fr_FR.UTF-8' , self .run_js ('a.out.js' ))
4563
+ self .emcc_args += ['--pre-js' , 'preamble.js' ]
4564
+ self .do_runf (path_from_root ('tests' , 'test_browser_language_detection.c' ), 'fr_FR.UTF-8' )
4575
4565
4576
4566
def test_js_main (self ):
4577
4567
# try to add a main() from JS, at runtime. this is not supported (the
@@ -4583,9 +4573,8 @@ def test_js_main(self):
4583
4573
};
4584
4574
''' )
4585
4575
create_test_file ('src.cpp' , '' )
4586
- self .run_process ([EMCC , 'src.cpp' , '--pre-js' , 'pre_main.js' ])
4587
- self .assertContained ('compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]' ,
4588
- self .run_js ('a.out.js' , assert_returncode = NON_ZERO ))
4576
+ self .emcc_args += ['--pre-js' , 'pre_main.js' ]
4577
+ self .do_runf ('src.cpp' , 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]' , assert_returncode = NON_ZERO )
4589
4578
4590
4579
def test_locale_wrong (self ):
4591
4580
create_test_file ('src.cpp' , r'''
@@ -4676,8 +4665,8 @@ def test_no_filesystem(self):
4676
4665
self .assertLess (no_size , 360000 )
4677
4666
4678
4667
def test_no_filesystem_libcxx (self ):
4679
- self .run_process ([ EMCC , path_from_root ( 'tests ' , 'hello_libcxx.cpp' ), '-s' , 'FILESYSTEM=0' ] )
4680
- self .assertContained ( 'hello, world! ' , self . run_js ( 'a.out.js' ) )
4668
+ self .set_setting ( 'FILESYSTEM ' , 0 )
4669
+ self .do_runf ( path_from_root ( 'tests ' , 'hello_libcxx.cpp' ), 'hello, world!' )
4681
4670
4682
4671
@is_slow_test
4683
4672
def test_no_nuthin (self ):
@@ -4721,7 +4710,8 @@ def test_no_browser(self):
4721
4710
self .run_process ([EMCC , path_from_root ('tests' , 'hello_world.c' )])
4722
4711
self .assertNotContained (BROWSER_INIT , open ('a.out.js' ).read ())
4723
4712
4724
- self .run_process ([EMCC , path_from_root ('tests' , 'browser_main_loop.c' )]) # uses emscripten_set_main_loop, which needs Browser
4713
+ # uses emscripten_set_main_loop, which needs Browser
4714
+ self .run_process ([EMCC , path_from_root ('tests' , 'browser_main_loop.c' )])
4725
4715
self .assertContained (BROWSER_INIT , open ('a.out.js' ).read ())
4726
4716
4727
4717
def test_EXPORTED_RUNTIME_METHODS (self ):
@@ -4797,8 +4787,7 @@ def test_stat_fail_alongtheway(self):
4797
4787
return fail;
4798
4788
}
4799
4789
''' )
4800
- self .run_process ([EMCC , 'src.cpp' ])
4801
- self .assertContained (r'''pass: mkdir("path", 0777) == 0
4790
+ self .do_runf ('src.cpp' , r'''pass: mkdir("path", 0777) == 0
4802
4791
pass: close(open("path/file", O_CREAT | O_WRONLY, 0644)) == 0
4803
4792
pass: stat("path", &st) == 0
4804
4793
pass: st.st_mode = 0777
@@ -4813,7 +4802,7 @@ def test_stat_fail_alongtheway(self):
4813
4802
pass: lstat("path/file/impossible", &st) == -1
4814
4803
info: errno=54 Not a directory
4815
4804
pass: error == ENOTDIR
4816
- ''' , self . run_js ( 'a.out.js' ) )
4805
+ ''' )
4817
4806
4818
4807
def test_link_with_a_static (self ):
4819
4808
create_test_file ('x.c' , r'''
@@ -4953,7 +4942,6 @@ class Descriptor {
4953
4942
4954
4943
Descriptor desc;
4955
4944
''' )
4956
- try_delete ('a.out.js' )
4957
4945
self .run_process ([EMCC , 'src.cpp' , '-O2' , '-s' , 'EXPORT_ALL' ])
4958
4946
self .assertExists ('a.out.js' )
4959
4947
@@ -5002,10 +4990,10 @@ def test_sdl2_config(self):
5002
4990
]:
5003
4991
print (args , expected )
5004
4992
out = self .run_process ([PYTHON , path_from_root ('system' , 'bin' , 'sdl2-config' )] + args , stdout = PIPE , stderr = PIPE ).stdout
5005
- assert expected in out , out
4993
+ self . assertContained ( expected , out )
5006
4994
print ('via emmake' )
5007
4995
out = self .run_process ([emmake , 'sdl2-config' ] + args , stdout = PIPE , stderr = PIPE ).stdout
5008
- assert expected in out , out
4996
+ self . assertContained ( expected , out )
5009
4997
5010
4998
def test_module_onexit (self ):
5011
4999
create_test_file ('src.cpp' , r'''
@@ -5017,7 +5005,6 @@ def test_module_onexit(self):
5017
5005
return 14;
5018
5006
}
5019
5007
''' )
5020
- try_delete ('a.out.js' )
5021
5008
self .run_process ([EMCC , 'src.cpp' , '-s' , 'EXIT_RUNTIME' ])
5022
5009
self .assertContained ('exiting now, status 14' , self .run_js ('a.out.js' , assert_returncode = 14 ))
5023
5010
@@ -7553,11 +7540,9 @@ def test_check_source_map_args(self):
7553
7540
'profiling' : ['--profiling' ] # -g4 --profiling should still emit a source map; see #8584
7554
7541
})
7555
7542
def test_check_sourcemapurl_default (self , * args ):
7556
- print (args )
7557
7543
if not self .is_wasm ():
7558
7544
self .skipTest ('only supported with wasm' )
7559
7545
7560
- try_delete ('a.wasm.map' )
7561
7546
self .run_process ([EMCC , path_from_root ('tests' , 'hello_123.c' ), '-g4' , '-o' , 'a.js' ] + list (args ))
7562
7547
output = open ('a.wasm' , 'rb' ).read ()
7563
7548
# has sourceMappingURL section content and points to 'a.wasm.map' file
0 commit comments