From 42691f0d943b43842e69b76608cbe4416e35e94e Mon Sep 17 00:00:00 2001 From: Alois Wohlschlager Date: Mon, 22 Sep 2025 18:36:12 +0200 Subject: [PATCH] functional2: fix in the development shell The functional2 test suite was broken in the development shell for two mostly separate reasons leading to "no such file or directory" errors: * The `BUILD_TEST_SHELL` (already containing the correct path) would always be set from the Meson option `build_test_shell`, even to the empty string if that option is not set. Skip the overwrite in this case to make the environment variable work again. * Sandboxed builds would fail to find their builder `/bin/sh`, since in the development shell busybox is not found, so no sandbox shell gets configured. Use the shell from `BUILD_TEST_SHELL` instead. (How this does not break the old functional tests remains a mystery.) Change-Id: I6a6a696424e8caaef3f9b68e3738bfd58ea0b056 --- tests/functional2/meson.build | 4 +++- tests/functional2/testlib/global_assets/config.nix.template | 2 +- tests/functional2/testlib/utils.py | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/functional2/meson.build b/tests/functional2/meson.build index 2b606274d..4e2b116ca 100644 --- a/tests/functional2/meson.build +++ b/tests/functional2/meson.build @@ -15,7 +15,9 @@ functional2_env = environment() # set the bin dir for us to know where to find the lix binaries for our declarative path # without leaking all of PATH or env functional2_env.set('NIX_BIN_DIR', bindir) -functional2_env.set('BUILD_TEST_SHELL', build_test_shell) +if build_test_shell != '' + functional2_env.set('BUILD_TEST_SHELL', build_test_shell) +endif functional2_env.set('system', host_system) test( diff --git a/tests/functional2/testlib/global_assets/config.nix.template b/tests/functional2/testlib/global_assets/config.nix.template index bb6b331f2..ad68f5507 100644 --- a/tests/functional2/testlib/global_assets/config.nix.template +++ b/tests/functional2/testlib/global_assets/config.nix.template @@ -17,7 +17,7 @@ rec { mkDerivation = args: derivation ({ inherit system; - builder = "/bin/sh"; + builder = "@shell@"; args = ["-e" args.builder or (builtins.toFile "builder-${args.name}.sh" '' if [ -e "$NIX_ATTRS_SH_FILE" ]; then source $NIX_ATTRS_SH_FILE; fi; eval "$buildCommand" diff --git a/tests/functional2/testlib/utils.py b/tests/functional2/testlib/utils.py index 07343c60a..c486b7729 100644 --- a/tests/functional2/testlib/utils.py +++ b/tests/functional2/testlib/utils.py @@ -144,6 +144,7 @@ def get_global_asset(name: str) -> Fileish: "system": os.environ.get("system"), # noqa: SIM112 # system is actually lowercase here # Either just the build shell or entire global path if we are darwin "path": os.environ.get("BUILD_TEST_SHELL") or os.environ.get("PATH"), + "shell": Path(os.environ.get("BUILD_TEST_SHELL") or "/bin") / "sh", }, ) return CopyFile(functional2_base_folder / "testlib" / "global_assets" / name)