import subprocess, sys, os
repo = os.path.dirname(__file__)
python = os.path.join(repo, '.venv','Scripts','python.exe')
try:
    ret = subprocess.run([python, os.path.join(repo,'run_local_tests.py')], capture_output=True, text=True, timeout=300)
    out = f"RETURN CODE: {ret.returncode}\n\nSTDOUT:\n{ret.stdout}\n\nSTDERR:\n{ret.stderr}"
except Exception as e:
    out = f"EXCEPTION: {e}"
with open(os.path.join(repo,'run_local_tests_output.txt'),'w',encoding='utf-8') as f:
    f.write(out)
print('Runner finished, output saved to run_local_tests_output.txt')
