File indexing completed on 2025-02-25 09:17:22
0001 from pathlib import Path
0002 import os
0003 import json
0004 import functools
0005 import tarfile
0006 import urllib.request
0007 import subprocess
0008 import sys
0009 import re
0010 import collections
0011
0012 import pytest
0013
0014 from helpers import (
0015 geant4Enabled,
0016 rootEnabled,
0017 dd4hepEnabled,
0018 hepmc3Enabled,
0019 pythia8Enabled,
0020 exatrkxEnabled,
0021 onnxEnabled,
0022 AssertCollectionExistsAlg,
0023 failure_threshold,
0024 )
0025
0026
0027 def test_gsf_debugger(tmp_path):
0028 path = (
0029 Path(__file__).parent.parent.parent.parent
0030 / "Examples"
0031 / "Scripts"
0032 / "GsfDebugger"
0033 )
0034 scriptdir = (
0035 Path(__file__).parent.parent.parent.parent / "Examples" / "Scripts" / "Python"
0036 )
0037
0038 gsf_script = path / "make_gsf_verbose_log.py"
0039 assert gsf_script.exists()
0040
0041 debugger = path / "src/main.py"
0042 assert debugger.exists()
0043
0044 env = os.environ.copy()
0045 env["PYTHONPATH"] = f"{scriptdir}:{env['PYTHONPATH']}"
0046 gsf_result = subprocess.run(
0047 [sys.executable, gsf_script], capture_output=True, cwd=tmp_path, env=env
0048 )
0049
0050 logfile = tmp_path / "test.log"
0051 with open(logfile, "w") as f:
0052 f.write(gsf_result.stdout.decode("utf8"))
0053
0054 assert gsf_result.returncode == 0
0055
0056 debugger_result = subprocess.run(
0057 [sys.executable, debugger, f"--logfile={logfile}", "--nogui"], cwd=tmp_path
0058 )
0059 assert debugger_result.returncode == 0