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
@@ -294,7 +295,7 @@ def red_stderr():
294295
295296
296297def run_spec_tests ():
297- print ( ' \n [ checking wasm-shell spec testcases... ] \n ' )
298+ print_heading ( ' checking wasm-shell spec testcases...' )
298299
299300 worker_count = os .cpu_count ()
300301 print ("Running with" , worker_count , "workers" )
@@ -326,7 +327,7 @@ def run_spec_tests():
326327
327328
328329def run_validator_tests ():
329- print ( ' \n [ running validation tests... ] \n ' )
330+ print_heading ( ' running validation tests...' )
330331 # Ensure the tests validate by default
331332 cmd = shared .WASM_AS + [os .path .join (shared .get_test_dir ('validator' ), 'invalid_export.wast' ), '-o' , 'a.wasm' ]
332333 support .run_command (cmd )
@@ -343,7 +344,7 @@ def run_validator_tests():
343344
344345
345346def run_example_tests ():
346- print ( ' \n [ checking native example testcases...] \n ' )
347+ print_heading ( ' checking native example testcases...' )
347348 if not shared .NATIVECC or not shared .NATIVEXX :
348349 shared .fail_with_error ('Native compiler (e.g. gcc/g++) was not found in PATH!' )
349350 return
@@ -385,7 +386,7 @@ def run_example_tests():
385386
386387
387388def run_unittest ():
388- print ( ' \n [ checking unit tests...] \n ' )
389+ print_heading ( ' checking unit tests...' )
389390
390391 # equivalent to `python -m unittest discover -s ./test -v`
391392 suite = unittest .defaultTestLoader .discover (os .path .dirname (shared .options .binaryen_test ))
@@ -472,13 +473,13 @@ def main():
472473
473474 # Check/display the results
474475 if shared .num_failures == 0 :
475- print ( ' \n [ success! ]' )
476+ print_heading ( ' success!' , last = True )
476477
477478 if shared .warnings :
478479 print ('\n ' + '\n ' .join (shared .warnings ))
479480
480481 if shared .num_failures > 0 :
481- print ( ' \n [ ' + str ( shared .num_failures ) + ' failures! ]' )
482+ print_heading ( f' { shared .num_failures } failures!' , last = True )
482483 return 1
483484
484485 return 0
0 commit comments