This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
src/tools/rust-analyzer/crates Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff 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_owned ( ) ) ) ;
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
Original file line number Diff line number Diff 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.
406413pub fn project_root ( ) -> Utf8PathBuf {
407414 let dir = env ! ( "CARGO_MANIFEST_DIR" ) ;
You can’t perform that action at this time.
0 commit comments