@@ -54,6 +54,11 @@ fn dist_baseline() {
5454 & [ dist:: Std { compiler: Compiler { host: a, stage: 1 } , target: a } , ]
5555 ) ;
5656 assert_eq ! ( first( builder. cache. all:: <dist:: Src >( ) ) , & [ dist:: Src ] ) ;
57+ // Make sure rustdoc is only built once.
58+ assert_eq ! (
59+ first( builder. cache. all:: <tool:: Rustdoc >( ) ) ,
60+ & [ tool:: Rustdoc { compiler: Compiler { host: a, stage: 2 } } , ]
61+ ) ;
5762}
5863
5964#[ test]
@@ -414,3 +419,77 @@ fn test_exclude() {
414419 // Ensure other tests are not affected.
415420 assert ! ( builder. cache. contains:: <test:: RustdocUi >( ) ) ;
416421}
422+
423+ #[ test]
424+ fn doc_default ( ) {
425+ let mut config = configure ( & [ ] , & [ ] ) ;
426+ config. compiler_docs = true ;
427+ config. cmd = Subcommand :: Doc { paths : Vec :: new ( ) , open : false } ;
428+ let build = Build :: new ( config) ;
429+ let mut builder = Builder :: new ( & build) ;
430+ builder. run_step_descriptions ( & Builder :: get_step_descriptions ( Kind :: Doc ) , & [ ] ) ;
431+ let a = INTERNER . intern_str ( "A" ) ;
432+
433+ // error_index_generator uses stage 1 to share rustdoc artifacts with the
434+ // rustdoc tool.
435+ assert_eq ! (
436+ first( builder. cache. all:: <doc:: ErrorIndex >( ) ) ,
437+ & [ doc:: ErrorIndex { compiler: Compiler { host: a, stage: 1 } , target: a } , ]
438+ ) ;
439+ assert_eq ! (
440+ first( builder. cache. all:: <tool:: ErrorIndex >( ) ) ,
441+ & [ tool:: ErrorIndex { compiler: Compiler { host: a, stage: 1 } } ]
442+ ) ;
443+ // This is actually stage 1, but Rustdoc::run swaps out the compiler with
444+ // stage minus 1 if --stage is not 0. Very confusing!
445+ assert_eq ! (
446+ first( builder. cache. all:: <tool:: Rustdoc >( ) ) ,
447+ & [ tool:: Rustdoc { compiler: Compiler { host: a, stage: 2 } } , ]
448+ ) ;
449+ }
450+
451+ #[ test]
452+ fn test_docs ( ) {
453+ // Behavior of `x.py test` doing various documentation tests.
454+ let mut config = configure ( & [ ] , & [ ] ) ;
455+ config. cmd = Subcommand :: Test {
456+ paths : vec ! [ ] ,
457+ test_args : vec ! [ ] ,
458+ rustc_args : vec ! [ ] ,
459+ fail_fast : true ,
460+ doc_tests : DocTests :: Yes ,
461+ bless : false ,
462+ compare_mode : None ,
463+ rustfix_coverage : false ,
464+ pass : None ,
465+ } ;
466+ let build = Build :: new ( config) ;
467+ let mut builder = Builder :: new ( & build) ;
468+ builder. run_step_descriptions ( & Builder :: get_step_descriptions ( Kind :: Test ) , & [ ] ) ;
469+ let a = INTERNER . intern_str ( "A" ) ;
470+
471+ // error_index_generator uses stage 1 to share rustdoc artifacts with the
472+ // rustdoc tool.
473+ assert_eq ! (
474+ first( builder. cache. all:: <doc:: ErrorIndex >( ) ) ,
475+ & [ doc:: ErrorIndex { compiler: Compiler { host: a, stage: 1 } , target: a } , ]
476+ ) ;
477+ assert_eq ! (
478+ first( builder. cache. all:: <tool:: ErrorIndex >( ) ) ,
479+ & [ tool:: ErrorIndex { compiler: Compiler { host: a, stage: 1 } } ]
480+ ) ;
481+ // Unfortunately rustdoc is built twice. Once from stage1 for compiletest
482+ // (and other things), and once from stage0 for std crates. Ideally it
483+ // would only be built once. If someone wants to fix this, it might be
484+ // worth investigating if it would be possible to test std from stage1.
485+ // Note that the stages here are +1 than what they actually are because
486+ // Rustdoc::run swaps out the compiler with stage minus 1 if --stage is
487+ // not 0.
488+ assert_eq ! (
489+ first( builder. cache. all:: <tool:: Rustdoc >( ) ) ,
490+ & [
491+ tool:: Rustdoc { compiler: Compiler { host: a, stage: 1 } } ,
492+ tool:: Rustdoc { compiler: Compiler { host: a, stage: 2 } } ,
493+ ]
494+ ) ;
495+ }
0 commit comments