Code cleanup and improvements.

This commit is contained in:
2026-09-03 21:52:06 +02:00
parent ea323e3ab0
commit ecdea827ac
20 changed files with 312 additions and 213 deletions

View File

@@ -12,7 +12,7 @@ import signal
import subprocess
import sys
import time
from typing import Any, Mapping, Sequence, TextIO
from typing import Any, Mapping, Sequence
from .config import AppConfig, project_root
from .filesystem import sha256_file, verify_known_game_hashes
@@ -190,7 +190,6 @@ def _run_standard_experiment(
_dry_run_commands(
config,
testcase,
result,
logger,
registry_before,
launch_argv,
@@ -1025,7 +1024,6 @@ def _preflight(
def _dry_run_commands(
config: AppConfig,
testcase: Testcase,
result: ResultDirectory,
logger: CommandLogger,
registry_before: DesktopRegistrySnapshot,
launch_argv: list[str],
@@ -1087,8 +1085,6 @@ def _run_and_watch(
process: subprocess.Popen[str] | None = None
process_identity: dict[str, Any] | None = None
failure_state: LogFileState | None = None
failure_analysis: dict[str, Any] | None = None
failure_text = ""
failure_trigger_mtime_ns: int | None = None
current_state: LogFileState | None = None
current_analysis: dict[str, Any] | None = None
@@ -1121,6 +1117,7 @@ def _run_and_watch(
error=str(exc),
)
raise ExperimentError(f"Could not launch experiment: {exc}") from exc
assert process is not None
logger.record_lifecycle(
argv,
state="started",
@@ -1156,8 +1153,6 @@ def _run_and_watch(
current_text = read_current_run_log_text(state, baseline)
if analysis.load_texture_to_material_failed:
failure_state = state
failure_analysis = analysis.to_summary()
failure_text = read_current_run_log_text(state, baseline)
failure_trigger_mtime_ns = state.mtime_ns
detected_at_ns = now_ns
post_failure_deadline_ns = now_ns + int(
@@ -1235,12 +1230,9 @@ def _run_and_watch(
final_states = snapshot_native_logs(config.paths.native_logs)
final_state = final_states.get(str(failure_state.path.absolute()))
if final_state is not None:
failure_state = final_state
failure_text = read_current_run_log_text(final_state, baseline)
failure_analysis = parse_current_run_log(final_state, baseline).to_summary()
current_state = final_state
current_text = failure_text
current_analysis = failure_analysis
current_text = read_current_run_log_text(final_state, baseline)
current_analysis = parse_current_run_log(final_state, baseline).to_summary()
if current_state is not None:
_write_text(result.path / "native.log", current_text)
whispering_vale = (
@@ -1381,8 +1373,13 @@ def _launch_argv(config: AppConfig, testcase: Testcase, result_directory: Path)
def _proton_command(config: AppConfig, *arguments: str) -> list[str]:
shim = Path(__file__).with_name("proton_compat.py")
return [sys.executable, str(shim), str(config.proton7.proton), *arguments]
shim = project_root() / "ptlinux/proton_compat.py"
return [
sys.executable,
str(shim),
str(config.proton7.proton),
*arguments,
]
def _runtime_environment(
@@ -1659,7 +1656,7 @@ def _collect_hashes(config: AppConfig, testcase: Testcase) -> list[dict[str, Any
config.proton7.prefix
/ "drive_c/windows/syswow64/d3dcompiler_43.dll": "native-d3dcompiler-43",
config.proton7.prefix / "drive_c/windows/syswow64/d3d9.dll": "dxvk-d3d9",
Path(__file__).with_name("proton_compat.py"): "proton-python314-shim",
project_root() / "ptlinux/proton_compat.py": "proton-python314-shim",
config.source: "local-config",
testcase.source: "testcase",
}