@@ -446,35 +446,61 @@ impl Step for RustAnalyzer {
446
446
447
447
/// Runs `cargo test` for rust-analyzer
448
448
fn run ( self , builder : & Builder < ' _ > ) {
449
- let host = self . compilers . target ( ) ;
449
+ let tool_result = builder. ensure ( tool:: RustAnalyzer :: from_compilers ( self . compilers ) ) ;
450
+ let build_compiler = tool_result. build_compiler ;
451
+ let target = self . compilers . target ( ) ;
452
+
453
+ let test_compiler = self . compilers . target ( ) ;
450
454
451
- let workspace_path = "src/tools/rust-analyzer" ;
452
- // until the whole RA test suite runs on `i686`, we only run
453
- // `proc-macro-srv` tests
454
- let crate_path = "src/tools/rust-analyzer/crates/proc-macro-srv" ;
455
455
let mut cargo = tool:: prepare_tool_cargo (
456
456
builder,
457
- self . compilers . build_compiler ( ) ,
457
+ build_compiler,
458
458
Mode :: ToolRustcPrivate ,
459
- host ,
459
+ target ,
460
460
Kind :: Test ,
461
- crate_path ,
461
+ "src/tools/rust-analyzer" ,
462
462
SourceType :: InTree ,
463
463
& [ "in-rust-tree" . to_owned ( ) ] ,
464
464
) ;
465
465
cargo. allow_features ( tool:: RustAnalyzer :: ALLOW_FEATURES ) ;
466
466
467
- let dir = builder. src . join ( workspace_path) ;
468
- // needed by rust-analyzer to find its own text fixtures, cf.
469
- // https://github.com/rust-analyzer/expect-test/issues/33
470
- cargo. env ( "CARGO_WORKSPACE_DIR" , & dir) ;
467
+ // N.B. it turns out _setting_ `CARGO_WORKSPACE_DIR` actually somehow breaks `expect-test`,
468
+ // even though previously we actually needed to set that hack to allow `expect-test` to
469
+ // correctly discover the r-a workspace instead of the outer r-l/r workspace.
471
470
472
- // RA's test suite tries to write to the source directory, that can't
473
- // work in Rust CI
471
+ // FIXME: RA's test suite tries to write to the source directory, that can't work in Rust CI
472
+ // without properly wiring up the writable test dir.
474
473
cargo. env ( "SKIP_SLOW_TESTS" , "1" ) ;
474
+ // FIXME: teach rust-analyzer to use `RUST_ANALYZER_TEST_DIR` for its test output root
475
+ // directory. In the rust-lang/rust CI, we separate checkout directory vs build directory,
476
+ // where the checkout directory is read-only whereas build directory (including test output
477
+ // directories) is writable.
478
+ let dir = testdir ( builder, target) ;
479
+ t ! ( fs:: create_dir_all( & dir) ) ;
480
+ cargo. env ( "RUST_ANALYZER_TEST_DIR" , dir) ;
481
+
482
+ // NOTE: we need to skip `src/tools/rust-analyzer/xtask` as they seem to exercise rustup /
483
+ // stable rustfmt.
484
+ //
485
+ // NOTE: you can only skip a specific workspace package via `--skip=...` if you *also*
486
+ // specify `--workspace`.
487
+ cargo. arg ( "--workspace" ) ;
488
+ cargo. arg ( "--exclude=xtask" ) ;
489
+
490
+ let mut skip_tests = vec ! [ ] ;
491
+
492
+ // Across all platforms
493
+ skip_tests. extend_from_slice ( & [
494
+ // FIXME: this test wants to find a `rustc`. We need to provide it with a path to staged
495
+ // in-tree `rustc`, but setting `RUSTC` env var requires some reworking of bootstrap.
496
+ "tests::smoke_test_real_sysroot_cargo" ,
497
+ ] ) ;
498
+
499
+ let skip_tests = skip_tests. iter ( ) . map ( |name| format ! ( "--skip={name}" ) ) . collect :: < Vec < _ > > ( ) ;
500
+ let skip_tests = skip_tests. iter ( ) . map ( |s| s. as_str ( ) ) . collect :: < Vec < _ > > ( ) ;
475
501
476
502
cargo. add_rustc_lib_path ( builder) ;
477
- run_cargo_test ( cargo, & [ ] , & [ ] , "rust-analyzer" , host , builder) ;
503
+ run_cargo_test ( cargo, skip_tests . as_slice ( ) , & [ ] , "rust-analyzer" , test_compiler , builder) ;
478
504
}
479
505
480
506
fn metadata ( & self ) -> Option < StepMetadata > {
0 commit comments