Skip to content

Give unit tests access to a $HOME directory #13370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

edolstra
Copy link
Member

Motivation

This allows them to not skip some tests that require a home directory (like anything that uses the fetcher cache).

Also, don't try to access cache.nixos.org in the libstore unit tests because that's bad for reproducibility.

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

Also, don't try to access cache.nixos.org in the libstore unit tests.
@edolstra edolstra requested a review from Ericson2314 June 17, 2025 09:15
@github-actions github-actions bot added the c api Nix as a C library with a stable interface label Jun 17, 2025
@@ -60,6 +60,7 @@ test(
env : {
'_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data',
'NIX_CONFIG': 'extra-experimental-features = flakes',
'HOME': meson.current_build_dir() / 'test-home',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: it would be better to use a temporary directory here, but I don't know how to do that in Meson.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mesonbuild/meson#14733 forwarding your question

Comment on lines +62 to +63
export HOME="$TMPDIR/home"
mkdir -p "$HOME"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nixpkgs now has writableTmpDirAsHomeHook. Seems like a good fit for this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c api Nix as a C library with a stable interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants