Skip to content

Commit

Permalink
rust: Add test for using system install of rust
Browse files Browse the repository at this point in the history
  • Loading branch information
Holzhaus committed Oct 4, 2022
1 parent d747b88 commit f1b7d9c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/languages/rust_test.py
Expand Up @@ -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'

0 comments on commit f1b7d9c

Please sign in to comment.