From c95237accd4e2946c4415f4bdbc6015c3aeb60eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 5 May 2025 12:19:40 +0200 Subject: [PATCH 1/2] test_ssh_remote: skip whole module at once on macOS --- pkgs/clan-cli/clan_cli/tests/test_ssh_remote.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/tests/test_ssh_remote.py b/pkgs/clan-cli/clan_cli/tests/test_ssh_remote.py index 279bc93f2..7dfdd67c7 100644 --- a/pkgs/clan-cli/clan_cli/tests/test_ssh_remote.py +++ b/pkgs/clan-cli/clan_cli/tests/test_ssh_remote.py @@ -11,6 +11,9 @@ from clan_cli.ssh.host import Host from clan_cli.ssh.host_key import HostKeyCheck from clan_cli.ssh.parse import parse_deployment_address +if sys.platform == "darwin": + pytest.skip("preload doesn't work on darwin", allow_module_level=True) + class ParseTestCase(NamedTuple): test_addr: str = "" @@ -132,10 +135,6 @@ def test_parse_ssh_options() -> None: assert host.ssh_options["StrictHostKeyChecking"] == "yes" -is_darwin = sys.platform == "darwin" - - -@pytest.mark.skipif(is_darwin, reason="preload doesn't work on darwin") def test_run(hosts: list[Host], runtime: AsyncRuntime) -> None: for host in hosts: proc = runtime.async_run( @@ -144,7 +143,6 @@ def test_run(hosts: list[Host], runtime: AsyncRuntime) -> None: assert proc.wait().result.stdout == "hello\n" -@pytest.mark.skipif(is_darwin, reason="preload doesn't work on darwin") def test_run_environment(hosts: list[Host], runtime: AsyncRuntime) -> None: for host in hosts: proc = runtime.async_run( @@ -167,7 +165,6 @@ def test_run_environment(hosts: list[Host], runtime: AsyncRuntime) -> None: assert "env_var=true" in p2.wait().result.stdout -@pytest.mark.skipif(is_darwin, reason="preload doesn't work on darwin") def test_run_no_shell(hosts: list[Host], runtime: AsyncRuntime) -> None: for host in hosts: proc = runtime.async_run( @@ -176,7 +173,6 @@ def test_run_no_shell(hosts: list[Host], runtime: AsyncRuntime) -> None: assert proc.wait().result.stdout == "hello\n" -@pytest.mark.skipif(is_darwin, reason="preload doesn't work on darwin") def test_run_function(hosts: list[Host], runtime: AsyncRuntime) -> None: def some_func(h: Host) -> bool: p = h.run(["echo", "hello"]) @@ -187,7 +183,6 @@ def test_run_function(hosts: list[Host], runtime: AsyncRuntime) -> None: assert proc.wait().result -@pytest.mark.skipif(is_darwin, reason="preload doesn't work on darwin") def test_timeout(hosts: list[Host], runtime: AsyncRuntime) -> None: for host in hosts: proc = runtime.async_run( @@ -197,7 +192,6 @@ def test_timeout(hosts: list[Host], runtime: AsyncRuntime) -> None: assert isinstance(error, ClanCmdTimeoutError) -@pytest.mark.skipif(is_darwin, reason="preload doesn't work on darwin") def test_run_exception(hosts: list[Host], runtime: AsyncRuntime) -> None: for host in hosts: proc = runtime.async_run( @@ -217,7 +211,6 @@ def test_run_exception(hosts: list[Host], runtime: AsyncRuntime) -> None: raise AssertionError(msg) -@pytest.mark.skipif(is_darwin, reason="preload doesn't work on darwin") def test_run_function_exception(hosts: list[Host], runtime: AsyncRuntime) -> None: def some_func(h: Host) -> CmdOut: return h.run_local(["exit 1"], RunOpts(shell=True)) From 0f7328ab897984f05a10d0db4b430ce3ef41ac0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 13 May 2025 15:46:21 +0200 Subject: [PATCH 2/2] filter out test files from clan-cli source this means we can fix test without having to re-run the installation tests. --- pkgs/clan-cli/default.nix | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/pkgs/clan-cli/default.nix b/pkgs/clan-cli/default.nix index 29436ff2f..65aea9c1a 100644 --- a/pkgs/clan-cli/default.nix +++ b/pkgs/clan-cli/default.nix @@ -58,13 +58,16 @@ let (pythonRuntime.withPackages pyTestDeps) ]; - source = + nixFilter = import ../../lib/filter-clan-core/nix-filter.nix; + + cliSource = + source: runCommand "clan-cli-source" { nativeBuildInputs = [ jq ]; } '' - cp -r ${./.} $out + cp -r ${source} $out chmod -R +w $out # In cases where the devshell created this file, this will already exist @@ -78,6 +81,19 @@ let cp -r ${../../templates} $out/clan_cli/templates ''; + sourceWithoutTests = cliSource ( + nixFilter.filter { + root = ./.; + include = [ + ( + _root: path: _type: + (builtins.match "test_.*\.py" path) == null + ) + ]; + } + ); + sourceWithTests = cliSource ./.; + # Create a custom nixpkgs for use within the project nixpkgs' = runCommand "nixpkgs" @@ -106,7 +122,7 @@ let in pythonRuntime.pkgs.buildPythonApplication { name = "clan-cli"; - src = source; + src = sourceWithoutTests; format = "pyproject"; # Arguments for the wrapper to unset LD_LIBRARY_PATH to avoid glibc version issues @@ -150,7 +166,7 @@ pythonRuntime.pkgs.buildPythonApplication { } '' set -euo pipefail - cp -r ${source} ./src + cp -r ${sourceWithTests} ./src chmod +w -R ./src cd ./src @@ -193,7 +209,7 @@ pythonRuntime.pkgs.buildPythonApplication { } '' set -euo pipefail - cp -r ${source} ./src + cp -r ${sourceWithTests} ./src chmod +w -R ./src cd ./src @@ -246,7 +262,7 @@ pythonRuntime.pkgs.buildPythonApplication { } '' set -euo pipefail - cp -r ${source} ./src + cp -r ${sourceWithTests} ./src chmod +w -R ./src cd ./src