fail-checker.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env python3
  2. import argparse
  3. from typing import List
  4. from junit_utils import iter_xml_files
  5. def check_for_fail(paths: List[str]):
  6. failed_list = []
  7. error_list = []
  8. for path in paths:
  9. for fn, suite, case in iter_xml_files(path):
  10. is_failure = case.find("failure") is not None
  11. is_error = case.find("error") is not None
  12. test_name = f"{case.get('classname')}/{case.get('name')}"
  13. if is_failure:
  14. failed_list.append((test_name, fn))
  15. elif is_error:
  16. error_list.append((test_name, fn))
  17. if failed_list or error_list:
  18. print(f"::error::You have failed tests")
  19. for t, fn in failed_list:
  20. print(f"failure: {t} ({fn})")
  21. for t, fn in error_list:
  22. print(f"error: {t} ({fn})")
  23. raise SystemExit(-1)
  24. def main():
  25. parser = argparse.ArgumentParser()
  26. parser.add_argument("path", nargs="+", help="jsuite xml reports directories")
  27. args = parser.parse_args()
  28. check_for_fail(args.path)
  29. if __name__ == "__main__":
  30. main()