mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-29 02:52:11 +00:00
fix target dir test
This commit is contained in:
parent
1db9402558
commit
66253b6553
2 changed files with 11 additions and 2 deletions
|
|
@ -3798,8 +3798,10 @@ mod tests {
|
||||||
(config, _, _) = config.apply_change(change);
|
(config, _, _) = config.apply_change(change);
|
||||||
|
|
||||||
assert_eq!(config.cargo_targetDir(None), &Some(TargetDirectory::UseSubdirectory(true)));
|
assert_eq!(config.cargo_targetDir(None), &Some(TargetDirectory::UseSubdirectory(true)));
|
||||||
|
let target =
|
||||||
|
Utf8PathBuf::from(std::env::var("CARGO_TARGET_DIR").unwrap_or("target".to_owned()));
|
||||||
assert!(
|
assert!(
|
||||||
matches!(config.flycheck(None), FlycheckConfig::CargoCommand { options, .. } if options.target_dir == Some(Utf8PathBuf::from("target/rust-analyzer")))
|
matches!(config.flycheck(None), FlycheckConfig::CargoCommand { options, .. } if options.target_dir == Some(target.join("rust-analyzer")))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -396,12 +396,19 @@ pub fn skip_slow_tests() -> bool {
|
||||||
if should_skip {
|
if should_skip {
|
||||||
eprintln!("ignoring slow test");
|
eprintln!("ignoring slow test");
|
||||||
} else {
|
} else {
|
||||||
let path = project_root().join("./target/.slow_tests_cookie");
|
let path = target_dir().join(".slow_tests_cookie");
|
||||||
fs::write(path, ".").unwrap();
|
fs::write(path, ".").unwrap();
|
||||||
}
|
}
|
||||||
should_skip
|
should_skip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn target_dir() -> Utf8PathBuf {
|
||||||
|
match std::env::var("CARGO_TARGET_DIR") {
|
||||||
|
Ok(target) => Utf8PathBuf::from(target),
|
||||||
|
Err(_) => project_root().join("target"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the path to the root directory of `rust-analyzer` project.
|
/// Returns the path to the root directory of `rust-analyzer` project.
|
||||||
pub fn project_root() -> Utf8PathBuf {
|
pub fn project_root() -> Utf8PathBuf {
|
||||||
let dir = env!("CARGO_MANIFEST_DIR");
|
let dir = env!("CARGO_MANIFEST_DIR");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue