mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-10 21:43:23 -05:00
fix: compute coverage from the profiles the site reads
This commit is contained in:
1 parent
72e47becb4
commit
519c02646a
3 files changed
+32
-2
No files matched your search
@@ -15,6 +15,7 @@ import json
|
||||
import os
|
||||
import sys
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from common import (
|
||||
@@ -33,17 +34,24 @@ import release_record
|
||||
from verify import verify_platform
|
||||
|
||||
|
||||
# The repository's profiles wherever the script is run from: a bare
|
||||
# "emulators" read the working directory, and a run elsewhere counted 0 cores.
|
||||
_EMULATORS_DIR = str(Path(__file__).resolve().parent.parent / "emulators")
|
||||
|
||||
|
||||
def compute_coverage(
|
||||
platform_name: str,
|
||||
platforms_dir: str,
|
||||
db: dict,
|
||||
data_registry: dict | None = None,
|
||||
supplemental_names: set[str] | None = None,
|
||||
emulators_dir: str = _EMULATORS_DIR,
|
||||
) -> dict:
|
||||
config = load_platform_config(platform_name, platforms_dir)
|
||||
result = verify_platform(
|
||||
config,
|
||||
db,
|
||||
emulators_dir,
|
||||
data_dir_registry=data_registry,
|
||||
supplemental_names=supplemental_names,
|
||||
)
|
||||
@@ -59,7 +67,7 @@ def compute_coverage(
|
||||
core_missing = len(undeclared) - core_present
|
||||
# Files a profile marks unsourceable never reach the undeclared list, so
|
||||
# the gap they represent has to be counted back in.
|
||||
profiles = load_emulator_profiles("emulators")
|
||||
profiles = load_emulator_profiles(emulators_dir)
|
||||
unsourceable_names = {
|
||||
f.get("name", "")
|
||||
for emu in resolve_platform_cores(config, profiles)
|
||||
|
||||
@@ -3587,7 +3587,8 @@ def main():
|
||||
for name in sorted(platform_names):
|
||||
try:
|
||||
cov = compute_coverage(
|
||||
name, args.platforms_dir, db, data_registry, suppl_names
|
||||
name, args.platforms_dir, db, data_registry, suppl_names,
|
||||
emulators_dir=args.emulators_dir,
|
||||
)
|
||||
coverages[name] = cov
|
||||
print(
|
||||
|
||||
@@ -31,5 +31,26 @@ class OneContributingText(unittest.TestCase):
|
||||
)
|
||||
|
||||
|
||||
|
||||
class CoverageReadsTheGivenProfiles(unittest.TestCase):
|
||||
"""generate_site --emulators-dir changed the emulator pages but not the
|
||||
platform coverage, which read ./emulators whatever was given."""
|
||||
|
||||
def test_the_directory_reaches_verify(self):
|
||||
from unittest import mock # noqa: PLC0415
|
||||
|
||||
seen: list[str] = []
|
||||
|
||||
def fake_verify(config, db, emulators_dir, **_kwargs):
|
||||
seen.append(emulators_dir)
|
||||
return {"status_counts": {}, "total_files": 0, "undeclared_files": [], "details": []}
|
||||
|
||||
with mock.patch.object(generate_readme, "verify_platform", fake_verify), \
|
||||
mock.patch.object(generate_readme, "load_emulator_profiles", return_value={}):
|
||||
generate_readme.compute_coverage(
|
||||
"retroarch", str(REPO_ROOT / "platforms"), {"files": {}}, emulators_dir="elsewhere"
|
||||
)
|
||||
self.assertEqual(seen, ["elsewhere"])
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user