Skip to content

Commit e7fe148

Browse files
committed
fix target dir test
1 parent c1bcef0 commit e7fe148

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

crates/rust-analyzer/src/config.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -3798,8 +3798,10 @@ mod tests {
37983798
(config, _, _) = config.apply_change(change);
37993799

38003800
assert_eq!(config.cargo_targetDir(None), &Some(TargetDirectory::UseSubdirectory(true)));
3801+
let target =
3802+
Utf8PathBuf::from(std::env::var("CARGO_TARGET_DIR").unwrap_or("target".to_string()));
38013803
assert!(
3802-
matches!(config.flycheck(None), FlycheckConfig::CargoCommand { options, .. } if options.target_dir == Some(Utf8PathBuf::from("target/rust-analyzer")))
3804+
matches!(config.flycheck(None), FlycheckConfig::CargoCommand { options, .. } if options.target_dir == Some(target.join("rust-analyzer")))
38033805
);
38043806
}
38053807

crates/test-utils/src/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -396,12 +396,19 @@ pub fn skip_slow_tests() -> bool {
396396
if should_skip {
397397
eprintln!("ignoring slow test");
398398
} else {
399-
let path = project_root().join("./target/.slow_tests_cookie");
399+
let path = target_dir().join(".slow_tests_cookie");
400400
fs::write(path, ".").unwrap();
401401
}
402402
should_skip
403403
}
404404

405+
pub fn target_dir() -> Utf8PathBuf {
406+
match std::env::var("CARGO_TARGET_DIR") {
407+
Ok(target) => Utf8PathBuf::from(target),
408+
Err(_) => project_root().join("target"),
409+
}
410+
}
411+
405412
/// Returns the path to the root directory of `rust-analyzer` project.
406413
pub fn project_root() -> Utf8PathBuf {
407414
let dir = env!("CARGO_MANIFEST_DIR");

0 commit comments

Comments
 (0)