Переглянути джерело

Allow fail-fast operation

This allows us to catch runtime errors that we would otherwise
miss.
nosoop 11 місяців тому
батько
коміт
77ee00a6c8
1 змінених файлів з 8 додано та 0 видалено
  1. 8 0
      src/smgdc/app.py

+ 8 - 0
src/smgdc/app.py

@@ -6,6 +6,7 @@ import dataclasses
 import os
 import pathlib
 import string
+import traceback
 
 from . import validate
 from .validate import LinuxBinary, PlatformBinary, WindowsBinary
@@ -39,6 +40,7 @@ def main() -> None:
     )
     parser.add_argument("-o", "--output-directory", type=pathlib.Path)
     parser.add_argument("--match", dest="matches", type=str, action="append")
+    parser.add_argument("--fail-fast", action="store_true")
 
     args = parser.parse_args()
 
@@ -91,6 +93,9 @@ def main() -> None:
             except Exception as e:
                 failed = True
                 print("- [FAIL]", name, f"({type(e).__name__}):", e)
+                if args.fail_fast:
+                    traceback.print_exception(e)
+                    return
 
         if args.output_directory:
             if failed:
@@ -111,6 +116,9 @@ def main() -> None:
                 print("- All checks passed; wrote output file")
             except Exception as e:
                 print(f"- Error writing output file; skipped ({type(e).__name__}):", e)
+                if args.fail_fast:
+                    traceback.print_exception(e)
+                    return
 
 
 if __name__ == "__main__":