fix: list a target's cores after its overrides

This commit is contained in:
Abdessamad Derraz committed 2026-10-10 11:17:53 +02:00
1 parent de795262d7
commit 26ea5336a7
2 files changed
+28 -8

No files matched your search

+7 -8
View File
@@ -363,21 +363,20 @@ def list_available_targets(
with open(target_file) as f:
data = yaml_load(f) or {}
overrides_file = os.path.join(targets_dir, "_overrides.yml")
overrides = {}
if os.path.exists(overrides_file):
with open(overrides_file) as f:
all_overrides = yaml_load(f) or {}
overrides = all_overrides.get(platform_name, {}).get("targets", {})
# The count --target filters on: overrides applied, as load_target_config
# applies them. The scraped list counted Batocera's machine variants and
# launchers, 198 cores shown for 187 used.
overrides = _target_overrides(platform_name, targets_dir)
result = []
for tname, tdata in sorted(data.get("targets", {}).items()):
aliases = overrides.get(tname, {}).get("aliases", [])
aliases = (overrides.get(tname) or {}).get("aliases", [])
cores = {str(c) for c in tdata.get("cores", [])}
result.append(
{
"name": tname,
"architecture": tdata.get("architecture", ""),
"core_count": len(tdata.get("cores", [])),
"core_count": len(apply_target_overrides(cores, overrides, tname)),
"aliases": aliases,
}
)
+21
View File
@@ -54,5 +54,26 @@ class TheBuilderNamesByTheCanonicalTarget(unittest.TestCase):
)
class TheListingCountsWhatTheFilterUses(unittest.TestCase):
"""--list-targets showed Batocera x86_64 with 198 cores; --target x86_64
filters on 187 once _overrides.yml removes machine variants and launchers."""
def test_every_listed_count_is_the_filtered_set(self):
from common import list_available_targets, load_target_config # noqa: PLC0415
platforms = str(REPO_ROOT / "platforms")
checked = 0
for target_file in sorted((REPO_ROOT / "platforms" / "targets").glob("[!_]*.yml")):
platform = target_file.stem
for row in list_available_targets(platform, platforms):
with self.subTest(platform=platform, target=row["name"]):
self.assertEqual(
row["core_count"],
len(load_target_config(platform, row["name"], platforms)),
)
checked += 1
self.assertGreater(checked, 0)
if __name__ == "__main__":
unittest.main()