with_crash_on_timeout.py 585 B

1234567891011121314151617181920212223
  1. from __future__ import print_function
  2. # TODO prettyboy remove after ya-bin release
  3. import os
  4. import sys
  5. import subprocess
  6. import json
  7. def main(args):
  8. meta_path = os.path.abspath(args[0])
  9. timeout_code = int(args[1])
  10. subprocess.check_call(args[2:])
  11. with open(meta_path) as f:
  12. meta_info = json.loads(f.read())
  13. if meta_info["exit_code"] == timeout_code:
  14. print(meta_info["project"], 'crashed by timeout, use --test-disable-timeout option', file=sys.stderr)
  15. return 1
  16. return 0
  17. if __name__ == '__main__':
  18. main(sys.argv[1:])