mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-17 07:07:52 -06:00
refactor: parse each source YAML once per run
This commit is contained in:
1 parent
141042dd81
commit
f0afe6a6fb
2 files changed
+50
-6
No files matched your search
@@ -23,5 +23,36 @@ class DataDirRefsAreRegistered(unittest.TestCase):
|
||||
self.assertEqual(validate_schemas._unknown_data_dir_refs(), [])
|
||||
|
||||
|
||||
|
||||
class EachSourceIsParsedOnce(unittest.TestCase):
|
||||
"""The schema pass, the data directory refs and the layout check each
|
||||
parsed every profile again: 2,038 parses for about 690 files."""
|
||||
|
||||
def test_three_checks_one_parse(self):
|
||||
import tempfile
|
||||
from unittest import mock
|
||||
|
||||
try:
|
||||
import validate_schemas
|
||||
except ImportError as exc:
|
||||
self.skipTest(f"validate_schemas needs jsonschema: {exc}")
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
root = Path(tmp)
|
||||
(root / "emulators").mkdir()
|
||||
(root / "platforms").mkdir()
|
||||
(root / "platforms" / "_data_dirs.yml").write_text("data_directories: {}\n")
|
||||
(root / "emulators" / "core.yml").write_text(
|
||||
"emulator: Core\nfiles:\n- name: a.bin\n path: .variants/a.bin\n")
|
||||
loaded = []
|
||||
real = validate_schemas.yaml_load
|
||||
with mock.patch.object(validate_schemas, "ROOT", root), \
|
||||
mock.patch.object(validate_schemas, "yaml_load",
|
||||
side_effect=lambda h: loaded.append(h.name) or real(h)):
|
||||
validate_schemas._validate_yaml_directory(root / "emulators", "emulator.schema.json")
|
||||
validate_schemas._unknown_data_dir_refs()
|
||||
layout = validate_schemas._repository_layout_in_profiles()
|
||||
self.assertEqual(sorted(Path(n).name for n in loaded), ["_data_dirs.yml", "core.yml"])
|
||||
self.assertEqual(len(layout), 1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user