tests/functional2/commands: fix failure with auto-allocate-uids

The custom subcommand test fixture used to replace the environment
with PATH prepended with the directory of the subcommand.
This caused the tests to fail on darwin with auto-allocate-uids
enabled, as the dynamic users aren't added to the user database
inside the sandbox, as opposed to linux.
Other environments were unaffected because the build user is a real user
with a database entry and HOME set.

Update the environment instead, also preserving hermetic env
created earlier by NixCommand constructor.

Change-Id: I7e59fd69ff13d1d395316d857b63a356e1648159
This commit is contained in:
Nikodem Rabuliński
2025-05-30 09:07:41 +02:00
parent 0c2ced0224
commit 3815dd5e64
@@ -96,7 +96,7 @@ def test_sub_commands(
):
# Test custom sub commands in various configurations
nix_command = nix.nix([custom_sub_command, "--version"], nix_exe=nix_exe)
nix_command.with_env(PATH=path)
nix_command.update_env(PATH=path)
if flag:
nix_command.settings.feature("lix-custom-sub-commands")
@@ -114,7 +114,7 @@ def test_sub_command_path_order(
# Test handling of the order of the path for custom sub commands
# Incidentally also tests passing through exit codes
nix_command = nix.nix([failing_sub_command, "--version"], nix_exe="lix")
nix_command.with_env(PATH=path_with_failure)
nix_command.update_env(PATH=path_with_failure)
nix_command.settings.feature("lix-custom-sub-commands")
nix_command.run().expect(expected)