@@ -9,6 +9,8 @@ use std::path::{Path, PathBuf};
9
9
use std:: { env, fs, iter} ;
10
10
11
11
use clap_complete:: shells;
12
+ #[ cfg( feature = "tracing" ) ]
13
+ use tracing:: instrument;
12
14
13
15
use crate :: core:: build_steps:: compile:: run_cargo;
14
16
use crate :: core:: build_steps:: doc:: DocumentationFormat ;
@@ -28,7 +30,7 @@ use crate::utils::helpers::{
28
30
linker_flags, t, target_supports_cranelift_backend, up_to_date,
29
31
} ;
30
32
use crate :: utils:: render_tests:: { add_flags_and_try_run_tests, try_run_tests} ;
31
- use crate :: { CLang , DocTests , GitRepo , Mode , PathSet , envify} ;
33
+ use crate :: { CLang , DocTests , GitRepo , Mode , PathSet , debug , envify} ;
32
34
33
35
const ADB_TEST_DIR : & str = "/data/local/tmp/work" ;
34
36
@@ -354,50 +356,136 @@ impl Step for RustAnalyzer {
354
356
const DEFAULT : bool = true ;
355
357
356
358
fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
357
- run. path ( "src/tools/rust-analyzer" )
359
+ run. path ( "src/tools/rust-analyzer" ) . alias ( "rust-analyzer" )
358
360
}
359
361
360
362
fn make_run ( run : RunConfig < ' _ > ) {
361
363
run. builder . ensure ( Self { stage : run. builder . top_stage , host : run. target } ) ;
362
364
}
363
365
364
- /// Runs `cargo test` for rust-analyzer
366
+ #[ cfg_attr(
367
+ feature = "tracing" ,
368
+ instrument(
369
+ level = "debug" ,
370
+ name = "RustAnalyzer::run" ,
371
+ skip_all,
372
+ fields( stage = self . stage, host = ?self . host) ,
373
+ ) ,
374
+ ) ]
375
+ fn run ( self , builder : & Builder < ' _ > ) {
376
+ debug ! ( stage = self . stage, host = ?self . host, "ensuring compiler" ) ;
377
+ let compiler = builder. compiler ( self . stage , self . host ) ;
378
+
379
+ debug ! ( stage = self . stage, host = ?self . host, "ensuring std" ) ;
380
+ builder. ensure ( compile:: Rustc :: new ( compiler, self . host ) ) ;
381
+
382
+ let mut cargo = tool:: prepare_tool_cargo (
383
+ builder,
384
+ compiler,
385
+ Mode :: ToolRustc ,
386
+ self . host ,
387
+ Kind :: Test ,
388
+ "src/tools/rust-analyzer" ,
389
+ SourceType :: InTree ,
390
+ & [ "in-rust-tree" . to_owned ( ) ] ,
391
+ ) ;
392
+ cargo. allow_features ( tool:: RustAnalyzer :: ALLOW_FEATURES ) ;
393
+
394
+ // RA's test suite tries to write to the source directory, that can't work in Rust CI.
395
+ cargo. env ( "SKIP_SLOW_TESTS" , "1" ) ;
396
+
397
+ // NOTE: unlike `proc-macro-srv` step, we must **not** set `CARGO_WORKSPACE_DIR` because I
398
+ // believe `src/tools/rust-analyzer/.cargo/config.toml`'s relative `CARGO_WORKSPACE_DIR`
399
+ // takes effect,
400
+
401
+ cargo. add_rustc_lib_path ( builder) ;
402
+ run_cargo_test (
403
+ cargo,
404
+ & [
405
+ // FIXME: may need a fix from https://github.com/rust-lang/rust-analyzer/pull/19124.
406
+ "--skip=config::tests::cargo_target_dir_subdir" ,
407
+ ] ,
408
+ & [ ] ,
409
+ "rust-analyzer" ,
410
+ "rust-analyzer" ,
411
+ self . host ,
412
+ builder,
413
+ ) ;
414
+ }
415
+ }
416
+
417
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
418
+ pub struct RustAnalyzerProcMacroSrv {
419
+ stage : u32 ,
420
+ host : TargetSelection ,
421
+ }
422
+
423
+ impl Step for RustAnalyzerProcMacroSrv {
424
+ type Output = ( ) ;
425
+ const ONLY_HOSTS : bool = true ;
426
+ const DEFAULT : bool = true ;
427
+
428
+ fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
429
+ run. path ( "src/tools/rust-analyzer/crates/proc-macro-srv" ) . alias ( "rust-analyzer" )
430
+ }
431
+
432
+ fn make_run ( run : RunConfig < ' _ > ) {
433
+ run. builder . ensure ( Self { stage : run. builder . top_stage , host : run. target } ) ;
434
+ }
435
+
436
+ #[ cfg_attr(
437
+ feature = "tracing" ,
438
+ instrument(
439
+ level = "debug" ,
440
+ name = "RustAnalyzerProcMacroSrv::run" ,
441
+ skip_all,
442
+ fields( stage = self . stage, host = ?self . host) ,
443
+ ) ,
444
+ ) ]
365
445
fn run ( self , builder : & Builder < ' _ > ) {
366
446
let stage = self . stage ;
367
447
let host = self . host ;
448
+
449
+ debug ! ( stage, ?host, "ensuring compiler" ) ;
368
450
let compiler = builder. compiler ( stage, host) ;
369
451
370
452
// We don't need to build the whole Rust Analyzer for the proc-macro-srv test suite,
371
453
// but we do need the standard library to be present.
454
+ debug ! ( stage, ?compiler, "ensuring std" ) ;
372
455
builder. ensure ( compile:: Rustc :: new ( compiler, host) ) ;
373
456
374
- let workspace_path = "src/tools/rust-analyzer" ;
375
- // until the whole RA test suite runs on `i686`, we only run
376
- // `proc-macro-srv` tests
377
- let crate_path = "src/tools/rust-analyzer/crates/proc-macro-srv" ;
457
+ debug ! ( "running `cargo test` on `src/tools/rust-analyzer/crates/proc-macro-srv`" ) ;
458
+
378
459
let mut cargo = tool:: prepare_tool_cargo (
379
460
builder,
380
461
compiler,
381
462
Mode :: ToolRustc ,
382
463
host,
383
464
Kind :: Test ,
384
- crate_path ,
465
+ "src/tools/rust-analyzer/crates/proc-macro-srv" ,
385
466
SourceType :: InTree ,
386
467
& [ "in-rust-tree" . to_owned ( ) ] ,
387
468
) ;
388
469
cargo. allow_features ( tool:: RustAnalyzer :: ALLOW_FEATURES ) ;
389
470
390
- let dir = builder. src . join ( workspace_path ) ;
391
- // needed by rust-analyzer to find its own text fixtures, cf.
392
- // https://github.com/rust-analyzer/expect-test/issues/33
471
+ let dir = builder. src . join ( "src/tools/rust-analyzer" ) ;
472
+ // Needed by rust-analyzer to find its own text fixtures, cf.
473
+ // https://github.com/rust-analyzer/expect-test/issues/33.
393
474
cargo. env ( "CARGO_WORKSPACE_DIR" , & dir) ;
394
475
395
- // RA's test suite tries to write to the source directory, that can't
396
- // work in Rust CI
476
+ // RA's test suite tries to write to the source directory, that can't work in Rust CI.
397
477
cargo. env ( "SKIP_SLOW_TESTS" , "1" ) ;
398
478
399
479
cargo. add_rustc_lib_path ( builder) ;
400
- run_cargo_test ( cargo, & [ ] , & [ ] , "rust-analyzer" , "rust-analyzer" , host, builder) ;
480
+ run_cargo_test (
481
+ cargo,
482
+ & [ ] ,
483
+ & [ ] ,
484
+ "rust-analyzer/crates/proc-macro-srv" ,
485
+ "rust-analyzer proc-macro-srv" ,
486
+ host,
487
+ builder,
488
+ ) ;
401
489
}
402
490
}
403
491
@@ -2618,14 +2706,14 @@ fn prepare_cargo_test(
2618
2706
cargo. arg ( "--quiet" ) ;
2619
2707
}
2620
2708
2621
- // The tests are going to run with the *target* libraries, so we need to
2622
- // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
2709
+ // The tests are going to run with the *target* libraries, so we need to ensure that those
2710
+ // libraries show up in the LD_LIBRARY_PATH equivalent.
2623
2711
//
2624
- // Note that to run the compiler we need to run with the *host* libraries,
2625
- // but our wrapper scripts arrange for that to be the case anyway.
2712
+ // Note that to run the compiler we need to run with the *host* libraries, but our wrapper
2713
+ // scripts arrange for that to be the case anyway.
2626
2714
//
2627
- // We skip everything on Miri as then this overwrites the libdir set up
2628
- // by `Cargo::new` and that actually makes things go wrong.
2715
+ // We skip everything on Miri as then this overwrites the libdir set up by `Cargo::new` and that
2716
+ // actually makes things go wrong.
2629
2717
if builder. kind != Kind :: Miri {
2630
2718
let mut dylib_path = dylib_path ( ) ;
2631
2719
dylib_path. insert ( 0 , PathBuf :: from ( & * builder. sysroot_target_libdir ( compiler, target) ) ) ;
0 commit comments