#!/usr/bin/env python3 """Reject original Python scripts that exit(0) before completing a test. Both a successful process exit and the test's final marker are required. """ import subprocess import sys marker, *command = sys.argv[1:] result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) sys.stdout.buffer.write(result.stdout) if result.returncode: sys.exit(result.returncode if result.returncode > 0 else 1) if marker.encode() not in result.stdout: print("Test stopped before its completion marker", file=sys.stderr) sys.exit(1)