@@ -459,35 +459,67 @@ impl Step for RustAnalyzer {
459459
460460 /// Runs `cargo test` for rust-analyzer
461461 fn run ( self , builder : & Builder < ' _ > ) {
462- let host = self . compilers . target ( ) ;
462+ let tool_result = builder. ensure ( tool:: RustAnalyzer :: from_compilers ( self . compilers ) ) ;
463+ let build_compiler = tool_result. build_compiler ;
464+ let target = self . compilers . target ( ) ;
463465
464- let workspace_path = "src/tools/rust-analyzer" ;
465- // until the whole RA test suite runs on `i686`, we only run
466- // `proc-macro-srv` tests
467- let crate_path = "src/tools/rust-analyzer/crates/proc-macro-srv" ;
468466 let mut cargo = tool:: prepare_tool_cargo (
469467 builder,
470- self . compilers . build_compiler ( ) ,
468+ build_compiler,
471469 Mode :: ToolRustcPrivate ,
472- host ,
470+ target ,
473471 Kind :: Test ,
474- crate_path ,
472+ "src/tools/rust-analyzer" ,
475473 SourceType :: InTree ,
476474 & [ "in-rust-tree" . to_owned ( ) ] ,
477475 ) ;
478476 cargo. allow_features ( tool:: RustAnalyzer :: ALLOW_FEATURES ) ;
479477
480- let dir = builder. src . join ( workspace_path) ;
481- // needed by rust-analyzer to find its own text fixtures, cf.
482- // https://github.com/rust-analyzer/expect-test/issues/33
483- cargo. env ( "CARGO_WORKSPACE_DIR" , & dir) ;
478+ // N.B. it turns out _setting_ `CARGO_WORKSPACE_DIR` actually somehow breaks `expect-test`,
479+ // even though previously we actually needed to set that hack to allow `expect-test` to
480+ // correctly discover the r-a workspace instead of the outer r-l/r workspace.
484481
485- // RA's test suite tries to write to the source directory, that can't
486- // work in Rust CI
482+ // FIXME: RA's test suite tries to write to the source directory, that can't work in Rust CI
483+ // without properly wiring up the writable test dir.
487484 cargo. env ( "SKIP_SLOW_TESTS" , "1" ) ;
488485
486+ // NOTE: we need to skip `src/tools/rust-analyzer/xtask` as they seem to exercise rustup /
487+ // stable rustfmt.
488+ //
489+ // NOTE: you can only skip a specific workspace package via `--exclude=...` if you *also*
490+ // specify `--workspace`.
491+ cargo. arg ( "--workspace" ) ;
492+ cargo. arg ( "--exclude=xtask" ) ;
493+
494+ // Skip running tests under `lib/` directory, since those auxiliary libraries cannot depend
495+ // on in-tree details.
496+ cargo. arg ( "--exclude=la-arena" ) ;
497+ cargo. arg ( "--exclude=line-index" ) ;
498+ cargo. arg ( "--exclude=lsp-server" ) ;
499+ cargo. arg ( "--exclude=smol_str" ) ;
500+ cargo. arg ( "--exclude=text-size" ) ;
501+ cargo. arg ( "--exclude=ungrammar" ) ;
502+
503+ let mut skip_tests = vec ! [ ] ;
504+
505+ // NOTE: the following test skips is a bit cheeky in that it assumes there are no
506+ // identically named tests across different r-a packages, where we want to run the
507+ // identically named test in one package but not another. If we want to support that use
508+ // case, we'd have to run the r-a tests in two batches (with one excluding the package that
509+ // we *don't* want to run the test for, and the other batch including).
510+
511+ // Across all platforms.
512+ skip_tests. extend_from_slice ( & [
513+ // FIXME: this test wants to find a `rustc`. We need to provide it with a path to staged
514+ // in-tree `rustc`, but setting `RUSTC` env var requires some reworking of bootstrap.
515+ "tests::smoke_test_real_sysroot_cargo" ,
516+ ] ) ;
517+
518+ let skip_tests = skip_tests. iter ( ) . map ( |name| format ! ( "--skip={name}" ) ) . collect :: < Vec < _ > > ( ) ;
519+ let skip_tests = skip_tests. iter ( ) . map ( |s| s. as_str ( ) ) . collect :: < Vec < _ > > ( ) ;
520+
489521 cargo. add_rustc_lib_path ( builder) ;
490- run_cargo_test ( cargo, & [ ] , & [ ] , "rust-analyzer" , host , builder) ;
522+ run_cargo_test ( cargo, skip_tests . as_slice ( ) , & [ ] , "rust-analyzer" , target , builder) ;
491523 }
492524
493525 fn metadata ( & self ) -> Option < StepMetadata > {
0 commit comments