From a078462013bd68ec7be48d703d1abacced2025e8 Mon Sep 17 00:00:00 2001 From: "Commentator2.0" Date: Tue, 21 Oct 2025 19:26:01 +0200 Subject: [PATCH] tests/functional2: refactor global assets make the global_assets folder more readable by placing asset pack files within a dedicated folder instead of building up a mess similar to f1 Change-Id: Ia2c16f38eb6da96e1e73584bd91391ee56acb410 --- .../dependencies.builder0.sh | 0 .../{ => dependencies}/dependencies.nix | 0 tests/functional2/testlib/utils.py | 23 ++++++++++++------- 3 files changed, 15 insertions(+), 8 deletions(-) rename tests/functional2/testlib/global_assets/{ => dependencies}/dependencies.builder0.sh (100%) rename tests/functional2/testlib/global_assets/{ => dependencies}/dependencies.nix (100%) diff --git a/tests/functional2/testlib/global_assets/dependencies.builder0.sh b/tests/functional2/testlib/global_assets/dependencies/dependencies.builder0.sh similarity index 100% rename from tests/functional2/testlib/global_assets/dependencies.builder0.sh rename to tests/functional2/testlib/global_assets/dependencies/dependencies.builder0.sh diff --git a/tests/functional2/testlib/global_assets/dependencies.nix b/tests/functional2/testlib/global_assets/dependencies/dependencies.nix similarity index 100% rename from tests/functional2/testlib/global_assets/dependencies.nix rename to tests/functional2/testlib/global_assets/dependencies/dependencies.nix diff --git a/tests/functional2/testlib/utils.py b/tests/functional2/testlib/utils.py index 935a02822..e035c0baf 100644 --- a/tests/functional2/testlib/utils.py +++ b/tests/functional2/testlib/utils.py @@ -18,7 +18,11 @@ from functional2.testlib.fixtures.file_helper import ( # Things have to be resolved from top to bottom, because otherwise the tests behave flakey # due to the internal file structure -functional2_base_folder = Path(__file__).parent.parent.absolute() +testlib_folder = Path(__file__).parent.absolute() + +global_assets_folder = testlib_folder / "global_assets" + +functional2_base_folder = testlib_folder.parent """ Resolves to `tests/functional2` folder """ @@ -150,14 +154,17 @@ def get_global_asset(name: str) -> Fileish: return CopyFile(functional2_base_folder / "testlib" / "global_assets" / name) -def get_global_asset_pack(name: Literal["dependencies"]) -> FileDeclaration: +def get_global_asset_pack(name: str) -> FileDeclaration: + def folder_to_assets(folder: str) -> FileDeclaration: + return { + f.name: get_global_asset(f"{folder}/{f.name}") + for f in (global_assets_folder / folder).iterdir() + } + match name: - case "dependencies": - return { - "config.nix": get_global_asset("config.nix"), - "dependencies.nix": get_global_asset("dependencies.nix"), - "dependencies.builder0.sh": get_global_asset("dependencies.builder0.sh"), - } + # default case, if its just config.nix + folder content + case _ if (global_assets_folder / name).exists(): + return {"config.nix": get_global_asset("config.nix")} | folder_to_assets(name) case _: msg = f"invalid pack name {name!r}" raise ValueError(msg)