mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 01:57:48 -06:00
fix: mark a standalone record from changed modules
frontend.script_modified looked at standalone_probe.py alone. The run's code now lives in five probes modules: a record from a checkout where one of them differs from the commit says so.
This commit is contained in:
1 parent
f61d6a187f
commit
75aef7e001
2 files changed
+42
-1
No files matched your search
@@ -7,6 +7,7 @@ import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
@@ -23,6 +24,11 @@ RECORD_VERSION = 4
|
||||
OBSERVABLES = ("verdict", "screens", "frame_hashes", "uniform_frames")
|
||||
SCRIPT = "scripts/standalone_probe.py"
|
||||
SCRIPT_PATH = REPO_ROOT / SCRIPT
|
||||
# The files that hold the code of a run: a record from a checkout where one
|
||||
# of them differs from the commit says so.
|
||||
CODE_FILES = (SCRIPT, "scripts/probes/standaloneemulators.py", "scripts/probes/appimage.py",
|
||||
"scripts/probes/xvfb.py", "scripts/probes/standalonerun.py",
|
||||
"scripts/probes/standalonerecord.py")
|
||||
|
||||
|
||||
class RunFailed(Exception):
|
||||
@@ -34,6 +40,22 @@ class Busy(Exception):
|
||||
"""The host's load is past the threshold a recorded run accepts."""
|
||||
|
||||
|
||||
def frontend_identity() -> dict:
|
||||
"""core_probe's frontend identity of the command, modified when any file
|
||||
that holds the run's code differs from the commit."""
|
||||
identity = cp.frontend_identity(SCRIPT_PATH, SCRIPT)
|
||||
if identity["script_modified"] is False:
|
||||
try:
|
||||
status = subprocess.run(["git", "status", "--porcelain", "--", *CODE_FILES], cwd=REPO_ROOT,
|
||||
capture_output=True, text=True, check=True).stdout
|
||||
except (OSError, subprocess.CalledProcessError) as exc:
|
||||
print(f"WARNING: frontend state unknown, git failed: {exc}", file=sys.stderr)
|
||||
identity["script_modified"] = None
|
||||
else:
|
||||
identity["script_modified"] = bool(status.strip())
|
||||
return identity
|
||||
|
||||
|
||||
def _variants(args: argparse.Namespace) -> list[cp.Variant]:
|
||||
if args.mode != "check":
|
||||
return [cp.Variant("default")]
|
||||
@@ -99,7 +121,7 @@ def measure(args: argparse.Namespace, emu: Emulator) -> dict:
|
||||
"core": {"file": meta["name"], "sha256": meta["sha256"], "repo": f"https://github.com/{meta['repo']}",
|
||||
"commit": None, "build_command": None, "compiler": None, "library_name": emu.name,
|
||||
"library_version": meta["tag"], "artifact": meta["url"]},
|
||||
"frontend": cp.frontend_identity(SCRIPT_PATH, SCRIPT),
|
||||
"frontend": frontend_identity(),
|
||||
"host": {**cp.host_identity(), "load_before": load_before, "load_after": load_after,
|
||||
"max_load": max_load},
|
||||
"inputs": {
|
||||
|
||||
@@ -162,6 +162,25 @@ class Oracle(unittest.TestCase):
|
||||
self.assertEqual(result["verdicts"], {"absent": "bios_error", "scph5501.bin": "boots"})
|
||||
|
||||
|
||||
class Frontend(unittest.TestCase):
|
||||
def test_a_modified_module_marks_the_record(self) -> None:
|
||||
from unittest import mock
|
||||
|
||||
clean = {"script": standalonerecord.SCRIPT, "commit": "0" * 40, "script_modified": False,
|
||||
"script_sha256": "1" * 64}
|
||||
changed = mock.Mock(stdout=" M scripts/probes/xvfb.py\n")
|
||||
with mock.patch.object(cp, "frontend_identity", return_value=dict(clean)), \
|
||||
mock.patch.object(standalonerecord.subprocess, "run", return_value=changed) as run:
|
||||
self.assertTrue(standalonerecord.frontend_identity()["script_modified"])
|
||||
self.assertEqual(run.call_args.args[0][4:], list(standalonerecord.CODE_FILES))
|
||||
|
||||
def test_the_code_files_are_the_modules_of_the_command(self) -> None:
|
||||
from tests.sources import script_paths
|
||||
|
||||
self.assertEqual({ROOT / name for name in standalonerecord.CODE_FILES},
|
||||
set(script_paths("standalone_probe.py")))
|
||||
|
||||
|
||||
class HostLock(unittest.TestCase):
|
||||
def test_a_run_holds_the_probe_lock_for_itself(self) -> None:
|
||||
import contextlib
|
||||
|
||||
Reference in new issue
Block a user