@@ -55,6 +55,13 @@ def is_split_memory(self):
5555 def is_wasm (self ):
5656 return 'BINARYEN' in str (self .emcc_args ) or self .is_wasm_backend ()
5757
58+ # Use closure in some tests for some additional coverage
59+ def maybe_closure (self ):
60+ if '-O2' in self .emcc_args or '-Os' in self .emcc_args :
61+ self .emcc_args += ['--closure' , '1' ]
62+ return True
63+ return False
64+
5865 def do_run_in_out_file_test (self , * path , ** kwargs ):
5966 test_path = path_from_root (* path )
6067
@@ -882,8 +889,7 @@ def test_exceptions(self):
882889 Settings .EXCEPTION_DEBUG = 1
883890
884891 Settings .DISABLE_EXCEPTION_CATCHING = 0
885- if '-O2' in self .emcc_args :
886- self .emcc_args += ['--closure' , '1' ] # Use closure here for some additional coverage
892+ self .maybe_closure ()
887893
888894 src = '''
889895 #include <stdio.h>
@@ -4089,8 +4095,7 @@ def test_langinfo(self):
40894095
40904096 def test_files (self ):
40914097 self .banned_js_engines = [SPIDERMONKEY_ENGINE ] # closure can generate variables called 'gc', which pick up js shell stuff
4092- if '-O2' in self .emcc_args :
4093- self .emcc_args += ['--closure' , '1' ] # Use closure here, to test we don't break FS stuff
4098+ if self .maybe_closure (): # Use closure here, to test we don't break FS stuff
40944099 self .emcc_args = [x for x in self .emcc_args if x != '-g' ] # ensure we test --closure 1 --memory-init-file 1 (-g would disable closure)
40954100 elif '-O3' in self .emcc_args and not self .is_wasm ():
40964101 print ('closure 2' )
@@ -5107,8 +5112,7 @@ def test_sse1(self):
51075112 orig_args = self .emcc_args
51085113 for mode in [[], ['-s' , 'SIMD=1' ]]:
51095114 self .emcc_args = orig_args + mode + ['-msse' ]
5110- if '-O2' in self .emcc_args :
5111- self .emcc_args += ['--closure' , '1' ] # Use closure here for some additional coverage
5115+ self .maybe_closure ()
51125116
51135117 self .do_run (open (path_from_root ('tests' , 'test_sse1.cpp' ), 'r' ).read (), 'Success!' )
51145118
@@ -5130,8 +5134,7 @@ def test_sse1_full(self):
51305134 orig_args = self .emcc_args
51315135 for mode in [[], ['-s' , 'SIMD=1' ]]:
51325136 self .emcc_args = orig_args + mode + ['-I' + path_from_root ('tests' ), '-msse' ]
5133- if '-O2' in self .emcc_args :
5134- self .emcc_args += ['--closure' , '1' ] # Use closure here for some additional coverage
5137+ self .maybe_closure ()
51355138
51365139 self .do_run (open (path_from_root ('tests' , 'test_sse1_full.cpp' ), 'r' ).read (), self .ignore_nans (native_result ), output_nicerizer = self .ignore_nans )
51375140
@@ -5153,8 +5156,7 @@ def test_sse2_full(self):
51535156 orig_args = self .emcc_args
51545157 for mode in [[], ['-s' , 'SIMD=1' ]]:
51555158 self .emcc_args = orig_args + mode + ['-I' + path_from_root ('tests' ), '-msse2' ] + args
5156- if '-O2' in self .emcc_args :
5157- self .emcc_args += ['--closure' , '1' ] # Use closure here for some additional coverage
5159+ self .maybe_closure ()
51585160
51595161 self .do_run (open (path_from_root ('tests' , 'test_sse2_full.cpp' ), 'r' ).read (), self .ignore_nans (native_result ), output_nicerizer = self .ignore_nans )
51605162
@@ -5463,8 +5465,7 @@ def test_sqlite(self):
54635465 force_c = True )
54645466
54655467 def test_zlib (self ):
5466- if '-O2' in self .emcc_args and 'ASM_JS=0' not in self .emcc_args : # without asm, closure minifies Math.imul badly
5467- self .emcc_args += ['--closure' , '1' ] # Use closure here for some additional coverage
5468+ self .maybe_closure ()
54685469
54695470 assert 'asm2g' in test_modes
54705471 if self .run_name == 'asm2g' :
0 commit comments