Files
libretro/tests/test_profile_repositories.py
T
Abdessamad Derraz 735f86283b refactor: split profile_sync into profiling
profile_sync.py keeps the command line: the parser, the flag checks,
profile selection against the branch, main, and the two steps that
read top-level modules (project_base, the site's source paths). The
library goes to one module per concern under scripts/profiling.

Tests that patched a name now patch the module their caller reads
it from. test_layers declares profiling with no sibling imports.
2026-11-18 12:49:20 +01:00

56 lines
1.9 KiB
Python

"""A profile names each repository under the name its forge answers today.
GitHub follows a renamed or transferred repository's old name in silence:
flycast2021 declared libretro/flycast, which answers as libretro/parallel-dc,
and reicast declared reicast/reicast-emulator, which answers as
skmp/reicast-emulator. profile_sync counts such a move as review work. This
test reads the forge answers profile_sync has cached and fails on any
profile still declaring an old name. Without a cache it has nothing to read
and skips.
"""
from __future__ import annotations
import tests
import unittest
from pathlib import Path
import yaml
from core import upstream
from profiling.repos import declared_repositories
REPO_ROOT = Path(__file__).resolve().parent.parent
CACHE = Path(upstream.CACHE_DIR)
if not CACHE.is_absolute():
CACHE = REPO_ROOT / CACHE
class DeclaredRepositoriesAreCurrent(unittest.TestCase):
def test_no_profile_declares_a_moved_repository(self) -> None:
if not (CACHE / "_api").is_dir():
self.skipTest("no forge answers cached")
checked = 0
moved = []
for path in sorted((REPO_ROOT / "emulators").glob("*.yml")):
profile = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
for field, _key, url in declared_repositories(profile):
repo = upstream.parse_repo(url)
if repo is None:
continue
current = upstream.current_slug(repo, str(CACHE), offline=True)
if current is None:
continue
checked += 1
if current.lower() != repo.slug.lower():
moved.append(f"{path.stem} {field}: {repo.slug} answers as {current}")
if not checked:
self.skipTest("no declared repository has a cached forge answer")
self.assertEqual(moved, [])
if __name__ == "__main__":
unittest.main()