2626from pathlib import Path
2727
2828from scripts .test import binaryenjs , finalize , shared , support , wasm2js , wasm_opt
29+ from scripts .test .shared import print_heading
2930
3031assert sys .version_info >= (3 , 10 ), 'requires Python 3.10'
3132
@@ -41,7 +42,7 @@ def get_changelog_version():
4142
4243
4344def run_version_tests ():
44- print ( '[ checking --version ... ] \n ' )
45+ print_heading ( ' checking --version ...' )
4546
4647 not_executable_suffix = ['.DS_Store' , '.txt' , '.js' , '.ilk' , '.pdb' , '.dll' , '.wasm' , '.manifest' ]
4748 executable_prefix = ['wasm' ]
@@ -67,7 +68,7 @@ def run_version_tests():
6768
6869
6970def run_wasm_dis_tests ():
70- print ( ' \n [ checking wasm-dis on provided binaries... ] \n ' )
71+ print_heading ( ' checking wasm-dis on provided binaries...' )
7172
7273 for t in shared .get_tests (shared .options .binaryen_test , ['.wasm' ]):
7374 print ('..' , os .path .basename (t ))
@@ -85,7 +86,7 @@ def run_wasm_dis_tests():
8586
8687
8788def run_crash_tests ():
88- print ( " \n [ checking we don't crash on tricky inputs... ] \n " )
89+ print_heading ( " checking we don't crash on tricky inputs..." )
8990
9091 for t in shared .get_tests (shared .get_test_dir ('crash' ), ['.wast' , '.wasm' ]):
9192 print ('..' , os .path .basename (t ))
@@ -95,7 +96,7 @@ def run_crash_tests():
9596
9697
9798def run_dylink_tests ():
98- print ( " \n [ we emit dylink sections properly... ] \n " )
99+ print_heading ( ' we emit dylink sections properly...' )
99100
100101 dylink_tests = glob .glob (os .path .join (shared .options .binaryen_test , 'dylib*.wasm' ))
101102 for t in sorted (dylink_tests ):
@@ -109,7 +110,7 @@ def run_dylink_tests():
109110
110111
111112def run_ctor_eval_tests ():
112- print ( ' \n [ checking wasm-ctor-eval... ] \n ' )
113+ print_heading ( ' checking wasm-ctor-eval...' )
113114
114115 for t in shared .get_tests (shared .get_test_dir ('ctor-eval' ), ['.wast' , '.wasm' ]):
115116 print ('..' , os .path .basename (t ))
@@ -126,7 +127,7 @@ def run_ctor_eval_tests():
126127
127128
128129def run_wasm_metadce_tests ():
129- print ( ' \n [ checking wasm-metadce ] \n ' )
130+ print_heading ( ' checking wasm-metadce' )
130131
131132 for t in shared .get_tests (shared .get_test_dir ('metadce' ), ['.wast' , '.wasm' ]):
132133 print ('..' , os .path .basename (t ))
@@ -141,10 +142,10 @@ def run_wasm_metadce_tests():
141142
142143def run_wasm_reduce_tests ():
143144 if not shared .has_shell_timeout ():
144- print ( ' \n [ skipping wasm-reduce testcases] \n ' )
145+ print_heading ( ' skipping wasm-reduce testcases' )
145146 return
146147
147- print ( ' \n [ checking wasm-reduce testcases] \n ' )
148+ print_heading ( ' checking wasm-reduce testcases' )
148149
149150 # fixed testcases
150151 for t in shared .get_tests (shared .get_test_dir ('reduce' ), ['.wast' ]):
@@ -161,7 +162,7 @@ def run_wasm_reduce_tests():
161162 # run on a nontrivial fuzz testcase, for general coverage
162163 # this is very slow in ThreadSanitizer, so avoid it there
163164 if 'fsanitize=thread' not in str (os .environ ):
164- print ( ' \n [ checking wasm-reduce fuzz testcase ] \n ' )
165+ print_heading ( ' checking wasm-reduce fuzz testcase' )
165166 # TODO: re-enable multivalue once it is better optimized
166167 support .run_command (shared .WASM_OPT + [os .path .join (shared .options .binaryen_test , 'lit/basic/signext.wast' ), '-ttf' , '-Os' , '-o' , 'a.wasm' , '--detect-features' , '--disable-multivalue' ])
167168 before = os .stat ('a.wasm' ).st_size
@@ -296,7 +297,7 @@ def red_stderr():
296297
297298
298299def run_spec_tests ():
299- print ( ' \n [ checking wasm-shell spec testcases... ] \n ' )
300+ print_heading ( ' checking wasm-shell spec testcases...' )
300301
301302 worker_count = os .cpu_count ()
302303 print ("Running with" , worker_count , "workers" )
@@ -328,7 +329,7 @@ def run_spec_tests():
328329
329330
330331def run_validator_tests ():
331- print ( ' \n [ running validation tests... ] \n ' )
332+ print_heading ( ' running validation tests...' )
332333 # Ensure the tests validate by default
333334 cmd = shared .WASM_AS + [os .path .join (shared .get_test_dir ('validator' ), 'invalid_export.wast' ), '-o' , 'a.wasm' ]
334335 support .run_command (cmd )
@@ -345,7 +346,7 @@ def run_validator_tests():
345346
346347
347348def run_example_tests ():
348- print ( ' \n [ checking native example testcases...] \n ' )
349+ print_heading ( ' checking native example testcases...' )
349350 if not shared .NATIVECC or not shared .NATIVEXX :
350351 shared .fail_with_error ('Native compiler (e.g. gcc/g++) was not found in PATH!' )
351352 return
@@ -387,7 +388,7 @@ def run_example_tests():
387388
388389
389390def run_unittest ():
390- print ( ' \n [ checking unit tests...] \n ' )
391+ print_heading ( ' checking unit tests...' )
391392
392393 # equivalent to `python -m unittest discover -s ./test -v`
393394 suite = unittest .defaultTestLoader .discover (os .path .dirname (shared .options .binaryen_test ))
@@ -471,16 +472,17 @@ def main():
471472
472473 for test in shared .requested :
473474 TEST_SUITES [test ]()
475+ print ()
474476
475477 # Check/display the results
476478 if shared .num_failures == 0 :
477- print ( ' \n [ success! ] ' )
479+ print_heading ( ' success!' )
478480
479481 if shared .warnings :
480482 print ('\n ' + '\n ' .join (shared .warnings ))
481483
482484 if shared .num_failures > 0 :
483- print ( ' \n [ ' + str ( shared .num_failures ) + ' failures! ] ' )
485+ print_heading ( f' { shared .num_failures } failures!' )
484486 return 1
485487
486488 return 0
0 commit comments