From 3c0434999e28f34c047b51fa3768d68ed88fb0ed Mon Sep 17 00:00:00 2001 From: Alois Wohlschlager Date: Sat, 1 Jun 2024 11:59:16 +0200 Subject: tests/libcmd: set HOME to a temporary directory The libcmd unit test creates files (more specifically, the fetcher cache) in its home directory. In the single-user sandbox, this leads to the creation of /homeless-shelter, since this is the default HOME and the root is writable. Unfortunately, this conflicts with the assumption of the functional tests that this directory does not exist. Use a different home directory to prevent these test failures, and thus restore the ability to build inside the single-user sandbox. Fixes: https://git.lix.systems/lix-project/lix/issues/365 Change-Id: I4df8c53d043234b95a7c0ac45fc5ee89e8d46aff --- tests/unit/meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unit/meson.build b/tests/unit/meson.build index 0d3f00ba5..c3eefeede 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -241,6 +241,10 @@ test( # No special meaning here, it's just a file laying around that is unlikely to go anywhere # any time soon. '_NIX_TEST_UNIT_DATA': meson.project_source_root() / 'src/nix-env/buildenv.nix', + # Use a temporary home directory for the unit tests. + # Otherwise, /homeless-shelter is created in the single-user sandbox, and functional tests will fail. + # TODO(alois31): handle TMPDIR properly (meson can't, and setting HOME in the test is too late)… + 'HOME': '/tmp/nix-test/libcmd-unit-tests', }, suite : 'check', protocol : 'gtest', -- cgit v1.2.3