@@ -994,23 +994,19 @@ impl Step for Compiletest {
994
994
}
995
995
996
996
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
997
- pub struct Docs {
997
+ struct DocTest {
998
998
compiler : Compiler ,
999
+ path : & ' static str ,
1000
+ name : & ' static str ,
1001
+ is_ext_doc : bool ,
999
1002
}
1000
1003
1001
- impl Step for Docs {
1004
+ impl Step for DocTest {
1002
1005
type Output = ( ) ;
1003
- const DEFAULT : bool = true ;
1004
1006
const ONLY_HOSTS : bool = true ;
1005
1007
1006
1008
fn should_run ( run : ShouldRun ) -> ShouldRun {
1007
- run. path ( "src/doc" )
1008
- }
1009
-
1010
- fn make_run ( run : RunConfig ) {
1011
- run. builder . ensure ( Docs {
1012
- compiler : run. builder . compiler ( run. builder . top_stage , run. host ) ,
1013
- } ) ;
1009
+ run. never ( )
1014
1010
}
1015
1011
1016
1012
/// Run `rustdoc --test` for all documentation in `src/doc`.
@@ -1026,9 +1022,9 @@ impl Step for Docs {
1026
1022
1027
1023
// Do a breadth-first traversal of the `src/doc` directory and just run
1028
1024
// tests for all files that end in `*.md`
1029
- let mut stack = vec ! [ build. src. join( "src/doc" ) ] ;
1025
+ let mut stack = vec ! [ build. src. join( self . path ) ] ;
1030
1026
let _time = util:: timeit ( ) ;
1031
- let _folder = build. fold_output ( || "test_docs" ) ;
1027
+ let _folder = build. fold_output ( || format ! ( "test_{}" , self . name ) ) ;
1032
1028
1033
1029
while let Some ( p) = stack. pop ( ) {
1034
1030
if p. is_dir ( ) {
@@ -1051,6 +1047,51 @@ impl Step for Docs {
1051
1047
}
1052
1048
}
1053
1049
1050
+ macro_rules! test_book {
1051
+ ( $( $name: ident, $path: expr, $book_name: expr, default =$default: expr; ) +) => {
1052
+ $(
1053
+ #[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
1054
+ pub struct $name {
1055
+ compiler: Compiler ,
1056
+ }
1057
+
1058
+ impl Step for $name {
1059
+ type Output = ( ) ;
1060
+ const DEFAULT : bool = $default;
1061
+ const ONLY_HOSTS : bool = true ;
1062
+
1063
+ fn should_run( run: ShouldRun ) -> ShouldRun {
1064
+ run. path( $path)
1065
+ }
1066
+
1067
+ fn make_run( run: RunConfig ) {
1068
+ run. builder. ensure( $name {
1069
+ compiler: run. builder. compiler( run. builder. top_stage, run. host) ,
1070
+ } ) ;
1071
+ }
1072
+
1073
+ fn run( self , builder: & Builder ) {
1074
+ builder. ensure( DocTest {
1075
+ compiler: self . compiler,
1076
+ path: $path,
1077
+ name: $book_name,
1078
+ is_ext_doc: !$default,
1079
+ } ) ;
1080
+ }
1081
+ }
1082
+ ) +
1083
+ }
1084
+ }
1085
+
1086
+ test_book ! (
1087
+ Nomicon , "src/doc/nomicon" , "nomicon" , default =false ;
1088
+ Reference , "src/doc/reference" , "reference" , default =false ;
1089
+ RustdocBook , "src/doc/rustdoc" , "rustdoc" , default =true ;
1090
+ RustByExample , "src/doc/rust-by-example" , "rust-by-example" , default =false ;
1091
+ TheBook , "src/doc/book" , "book" , default =false ;
1092
+ UnstableBook , "src/doc/unstable-book" , "unstable-book" , default =true ;
1093
+ ) ;
1094
+
1054
1095
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
1055
1096
pub struct ErrorIndex {
1056
1097
compiler : Compiler ,
0 commit comments