nixos-rebuild-ng: skip broken test for Nix < 2.18
The mock test for building with remote, but distinct target and build host checks a bunch of internals (how many shell commands are executed, which ones exactly) that are special cased on WITH_NIX_2_18, so the test breaks when that is false. I've opted to simply skip the test for now since the expected call list is very annoying to keep maintained and updated for multiple versions. This should fix NixOS configurations with config nix.package.version < 2.18. To keep it that way, I've added nixos-rebuild-ng with some nixVersions to passthru.tests that aren't likely to be removed in the short term.
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
installShellFiles,
|
||||
mkShell,
|
||||
nix,
|
||||
nixosTests,
|
||||
python3,
|
||||
python3Packages,
|
||||
runCommand,
|
||||
@@ -16,6 +15,10 @@
|
||||
# Very long tmp dirs lead to "too long for Unix domain socket"
|
||||
# SSH ControlPath errors. Especially macOS sets long TMPDIR paths.
|
||||
withTmpdir ? if stdenv.hostPlatform.isDarwin then "/tmp" else null,
|
||||
# passthru.tests
|
||||
nixosTests,
|
||||
nixVersions,
|
||||
nixos-rebuild-ng,
|
||||
}:
|
||||
let
|
||||
executable = if withNgSuffix then "nixos-rebuild-ng" else "nixos-rebuild";
|
||||
@@ -105,6 +108,17 @@ python3Packages.buildPythonApplication rec {
|
||||
};
|
||||
|
||||
tests = {
|
||||
with_nix_latest = nixos-rebuild-ng.override {
|
||||
nix = nixVersions.latest;
|
||||
};
|
||||
with_nix_stable = nixos-rebuild-ng.override {
|
||||
nix = nixVersions.stable;
|
||||
};
|
||||
with_nix_2_3 = nixos-rebuild-ng.override {
|
||||
# oldest / minimum supported version in nixpkgs
|
||||
nix = nixVersions.nix_2_3;
|
||||
};
|
||||
|
||||
inherit (nixosTests)
|
||||
nixos-rebuild-install-bootloader-ng
|
||||
nixos-rebuild-specialisations-ng
|
||||
|
||||
@@ -11,6 +11,7 @@ import pytest
|
||||
from pytest import MonkeyPatch
|
||||
|
||||
import nixos_rebuild as nr
|
||||
from nixos_rebuild.constants import WITH_NIX_2_18
|
||||
|
||||
from .helpers import get_qualified_name
|
||||
|
||||
@@ -514,6 +515,10 @@ def test_execute_nix_switch_flake(mock_run: Mock, tmp_path: Path) -> None:
|
||||
@patch("subprocess.run", autospec=True)
|
||||
@patch("uuid.uuid4", autospec=True)
|
||||
@patch(get_qualified_name(nr.cleanup_ssh), autospec=True)
|
||||
@pytest.mark.skipif(
|
||||
not WITH_NIX_2_18,
|
||||
reason="Tests internal logic based on the assumption that Nix >= 2.18",
|
||||
)
|
||||
def test_execute_nix_switch_build_target_host(
|
||||
mock_cleanup_ssh: Mock,
|
||||
mock_uuid4: Mock,
|
||||
|
||||
Reference in New Issue
Block a user