diff --git a/tests/languages/rust_test.py b/tests/languages/rust_test.py index acdf2ec5d..ce85c5602 100644 --- a/tests/languages/rust_test.py +++ b/tests/languages/rust_test.py @@ -76,3 +76,33 @@ def mocked_find_executable(exe: str) -> str | None: with rust.in_env(prefix, '1.64.0'): assert cmd_output('hello_world')[1] == 'Hello, world!\n' + + +@pytest.mark.skipif( + cmd_output('cargo', '--version', retcode=None)[0] != 0, + reason="requires working system installation of rust/cargo", +) +def test_installs_with_system_rust(tmpdir): + tmpdir.join('src', 'main.rs').ensure().write( + 'fn main() {' + ' println!("Hello, world!");' + '}', + ) + tmpdir.join('Cargo.toml').ensure().write( + toml.dumps({ + 'package': { + 'name': 'hello_world', + 'version': '0.1.0', + 'edition': '2021', + }, + 'dependencies': {}, + }), + ) + prefix = Prefix(str(tmpdir)) + rust.install_environment(prefix, 'system', ()) + + # this directory shouldn't exist, make sure we succeed without it existing + shutil.rmtree(tmpdir.join('target')) + + with rust.in_env(prefix, 'system'): + assert cmd_output('hello_world')[1] == 'Hello, world!\n'