refactor: build platform packs without printing

build_platform_pack and build_split_packs return what the build came to and print nothing. print_platform_pack holds the report lines, and generate_pack and generate_split_packs compose the two. The variant choice, the plan and the data directory pass return their notices instead of printing them. The callers that silenced stdout to get a record now call the builder.
This commit is contained in:
Abdessamad Derraz committed 2026-11-22 02:26:45 +01:00
1 parent 977d3f6874
commit d8570c6480
15 files changed
+295 -205

No files matched your search

+17 -19
View File
@@ -64,7 +64,7 @@ class _Fixture(unittest.TestCase):
def _both(self) -> tuple[dict, set[str]]:
from model.profiles import load_emulator_profiles
from model.platforms import load_platform_config
from packs.platformpack import generate_pack
from packs.platformpack import build_platform_pack
from packs.coverage import verify_platform
profiles = load_emulator_profiles(str(self.emulators))
@@ -72,12 +72,11 @@ class _Fixture(unittest.TestCase):
load_platform_config("paths", str(self.platforms)), self.db,
str(self.emulators), profiles,
)
with contextlib.redirect_stdout(io.StringIO()):
zip_path = generate_pack(
"paths", str(self.platforms), self.db, str(self.bios),
str(self.root / "out"), emulators_dir=str(self.emulators),
emu_profiles=profiles, offline=True,
)
zip_path = build_platform_pack(
"paths", str(self.platforms), self.db, str(self.bios),
str(self.root / "out"), emulators_dir=str(self.emulators),
emu_profiles=profiles, offline=True,
).zip_path
with zipfile.ZipFile(zip_path) as zf:
members = {n for n in zf.namelist() if n != "README.txt"}
return report, members
@@ -131,7 +130,7 @@ class ARequiredOnlyPack(_Fixture):
from model.profiles import load_emulator_profiles
from model.platforms import load_platform_config
from packs.archive import PackRecord
from packs.platformpack import generate_pack
from packs.platformpack import build_platform_pack
from packs.coverage import verify_platform
(self.emulators / "coreemu.yml").write_text(yaml.safe_dump({
@@ -145,17 +144,16 @@ class ARequiredOnlyPack(_Fixture):
)
profiles = load_emulator_profiles(str(self.emulators))
record = PackRecord()
with contextlib.redirect_stdout(io.StringIO()):
zip_path = generate_pack(
"paths", str(self.platforms), self.db, str(self.bios),
str(self.root / "out"), emulators_dir=str(self.emulators),
emu_profiles=profiles, offline=True, required_only=True,
)
generate_pack(
"paths", str(self.platforms), self.db, str(self.bios), "",
emulators_dir=str(self.emulators), emu_profiles=profiles,
offline=True, required_only=True, record=record,
)
zip_path = build_platform_pack(
"paths", str(self.platforms), self.db, str(self.bios),
str(self.root / "out"), emulators_dir=str(self.emulators),
emu_profiles=profiles, offline=True, required_only=True,
).zip_path
build_platform_pack(
"paths", str(self.platforms), self.db, str(self.bios), "",
emulators_dir=str(self.emulators), emu_profiles=profiles,
offline=True, required_only=True, record=record,
)
with zipfile.ZipFile(zip_path) as zf:
members = set(zf.namelist())
# The record names what the archive holds, nothing more or less.