11import sys
2+ import traceback
23from importlib import import_module
34from inspect import isfunction , signature
45from pkgutil import walk_packages
@@ -39,9 +40,12 @@ def main() -> None:
3940
4041 try :
4142 mod = import_module (item .name )
42- except (ImportError , SyntaxError ) as e :
43- print (f"{ _RUNNER_PROGRESS } Skip { item .name } : { e } " )
44- stats ["skipped" ] += 1
43+ except (ImportError , SyntaxError ):
44+ print (f"{ _RUNNER_PROGRESS } Load { item .name } " , end = "" )
45+ print (style_text (" [FAIL]" , _STYLE_FAILURE ))
46+ for line in traceback .format_exc ().splitlines ():
47+ print (f" { line } " )
48+ stats ["failed" ] += 1
4549 continue
4650
4751 # Skip modules without a valid main object
@@ -57,9 +61,10 @@ def main() -> None:
5761 mod_main ()
5862 print (style_text (" [PASS]" , _STYLE_SUCCESS ))
5963 stats ["passed" ] += 1
60- except Exception as e :
64+ except Exception :
6165 print (style_text (" [FAIL]" , _STYLE_FAILURE ))
62- print (f" Error in { item .name } : { e } " )
66+ for line in traceback .format_exc ().splitlines ():
67+ print (f" { line } " )
6368 stats ["failed" ] += 1
6469
6570 # Summary report
@@ -68,6 +73,9 @@ def main() -> None:
6873 print (f"Passed: { stats ['passed' ]} | Failed: { stats ['failed' ]} | Skipped: { stats ['skipped' ]} " )
6974 print ("=" * 30 )
7075
76+ if stats ["failed" ] > 0 :
77+ sys .exit (1 )
78+
7179
7280if __name__ == "__main__" :
7381 main ()
0 commit comments