File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ def get_default_version() -> str:
3434 # Just detecting the executable does not suffice, because if rustup is
3535 # installed but no toolchain is available, then `cargo` exists but
3636 # cannot be used without installing a toolchain first.
37- if cmd_output_b ('cargo' , '--version' , check = False )[0 ] == 0 :
37+ if cmd_output_b ('cargo' , '--version' , check = False , cwd = '/' )[0 ] == 0 :
3838 return 'system'
3939 else :
4040 return C .DEFAULT
Original file line number Diff line number Diff line change 99from pre_commit .languages import rust
1010from pre_commit .store import _make_local_repo
1111from testing .language_helpers import run_language
12+ from testing .util import cwd
1213
1314ACTUAL_GET_DEFAULT_VERSION = rust .get_default_version .__wrapped__
1415
@@ -29,6 +30,14 @@ def test_uses_default_when_rust_is_not_available(cmd_output_b_mck):
2930 assert ACTUAL_GET_DEFAULT_VERSION () == C .DEFAULT
3031
3132
33+ def test_selects_system_even_if_rust_toolchain_toml (tmp_path ):
34+ toolchain_toml = '[toolchain]\n channel = "wtf"\n '
35+ tmp_path .joinpath ('rust-toolchain.toml' ).write_text (toolchain_toml )
36+
37+ with cwd (tmp_path ):
38+ assert ACTUAL_GET_DEFAULT_VERSION () == 'system'
39+
40+
3241def _make_hello_world (tmp_path ):
3342 src_dir = tmp_path .joinpath ('src' )
3443 src_dir .mkdir ()
You can’t perform that action at this time.
0 commit comments