From c6ed5d47fd6611a05c7892d523c44fde34ccd1ea Mon Sep 17 00:00:00 2001 From: Al Sutton Date: Fri, 15 May 2026 10:35:13 +0100 Subject: [PATCH 1/4] Skip any tests that required rust to be installed when it isn't available --- tests/languages/rust_test.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/languages/rust_test.py b/tests/languages/rust_test.py index 52e356134..139420ff5 100644 --- a/tests/languages/rust_test.py +++ b/tests/languages/rust_test.py @@ -13,6 +13,12 @@ ACTUAL_GET_DEFAULT_VERSION = rust.get_default_version.__wrapped__ +def requires_locally_installed_cargo(): + return pytest.mark.skipif( + parse_shebang.find_executable('cargo') is None, + reason = "Cargo is not installed in the local environment" + ) + @pytest.fixture def cmd_output_b_mck(): @@ -20,16 +26,19 @@ def cmd_output_b_mck(): yield mck +@requires_locally_installed_cargo() def test_sets_system_when_rust_is_available(cmd_output_b_mck): cmd_output_b_mck.return_value = (0, b'', b'') assert ACTUAL_GET_DEFAULT_VERSION() == 'system' +@requires_locally_installed_cargo() def test_uses_default_when_rust_is_not_available(cmd_output_b_mck): cmd_output_b_mck.return_value = (127, b'', b'error: not found') assert ACTUAL_GET_DEFAULT_VERSION() == C.DEFAULT +@requires_locally_installed_cargo() def test_selects_system_even_if_rust_toolchain_toml(tmp_path): toolchain_toml = '[toolchain]\nchannel = "wtf"\n' tmp_path.joinpath('rust-toolchain.toml').write_text(toolchain_toml) @@ -84,6 +93,7 @@ def test_language_version_with_rustup(tmp_path, version): assert ret == (0, b'Hello, world!\n') +@requires_locally_installed_cargo() @pytest.mark.parametrize('dep', ('cli:shellharden:4.2.0', 'cli:shellharden')) def test_rust_cli_additional_dependencies(tmp_path, dep): _make_local_repo(str(tmp_path)) @@ -102,6 +112,7 @@ def test_rust_cli_additional_dependencies(tmp_path, dep): assert ret == (0, b'echo "$hi"\n') +@requires_locally_installed_cargo() def test_run_lib_additional_dependencies(tmp_path): _make_hello_world(tmp_path) From 8c704724c048b661118d0fcbfa5b333ea47411f8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 15 May 2026 09:44:30 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/languages/rust_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/languages/rust_test.py b/tests/languages/rust_test.py index 139420ff5..e6513a464 100644 --- a/tests/languages/rust_test.py +++ b/tests/languages/rust_test.py @@ -13,10 +13,11 @@ ACTUAL_GET_DEFAULT_VERSION = rust.get_default_version.__wrapped__ + def requires_locally_installed_cargo(): return pytest.mark.skipif( parse_shebang.find_executable('cargo') is None, - reason = "Cargo is not installed in the local environment" + reason='Cargo is not installed in the local environment', ) From dfe120b3e74d92494db32ece1629f4747aa6b013 Mon Sep 17 00:00:00 2001 From: Al Sutton Date: Fri, 15 May 2026 11:43:51 +0100 Subject: [PATCH 3/4] Move assert to a skipIf to ensure it's skipped on platforms where it isn't supported --- tests/languages/rust_test.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/languages/rust_test.py b/tests/languages/rust_test.py index e6513a464..60e814641 100644 --- a/tests/languages/rust_test.py +++ b/tests/languages/rust_test.py @@ -20,6 +20,12 @@ def requires_locally_installed_cargo(): reason='Cargo is not installed in the local environment', ) +def requires_locally_installed_rustup(): + return pytest.mark.skipif( + parse_shebang.find_executable('rustup') is None, + reason = "Cargo is not installed in the local environment" + ) + @pytest.fixture def cmd_output_b_mck(): @@ -83,10 +89,9 @@ def mck(exe, env=None): assert calls == ['rustup', 'rustup', 'cargo', 'hello_world'] assert ret == (0, b'Hello, world!\n') - +@requires_locally_installed_rustup() @pytest.mark.parametrize('version', (C.DEFAULT, '1.56.0')) def test_language_version_with_rustup(tmp_path, version): - assert parse_shebang.find_executable('rustup') is not None _make_hello_world(tmp_path) From 91cbcb5ab9f47f013621a8b108bc3ac26eb289da Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 15 May 2026 11:13:52 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/languages/rust_test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/languages/rust_test.py b/tests/languages/rust_test.py index 60e814641..a4c1a9570 100644 --- a/tests/languages/rust_test.py +++ b/tests/languages/rust_test.py @@ -20,10 +20,11 @@ def requires_locally_installed_cargo(): reason='Cargo is not installed in the local environment', ) + def requires_locally_installed_rustup(): return pytest.mark.skipif( parse_shebang.find_executable('rustup') is None, - reason = "Cargo is not installed in the local environment" + reason='Cargo is not installed in the local environment', ) @@ -89,6 +90,7 @@ def mck(exe, env=None): assert calls == ['rustup', 'rustup', 'cargo', 'hello_world'] assert ret == (0, b'Hello, world!\n') + @requires_locally_installed_rustup() @pytest.mark.parametrize('version', (C.DEFAULT, '1.56.0')) def test_language_version_with_rustup(tmp_path, version):