@@ -4,7 +4,6 @@ use std::thread;
4
4
5
5
fn configure ( host : & [ & str ] , target : & [ & str ] ) -> Config {
6
6
let mut config = Config :: default_opts ( ) ;
7
- config. stage = Some ( 2 ) ;
8
7
// don't save toolstates
9
8
config. save_toolstates = None ;
10
9
config. skip_only_host_steps = false ;
@@ -34,11 +33,101 @@ fn first<A, B>(v: Vec<(A, B)>) -> Vec<A> {
34
33
v. into_iter ( ) . map ( |( a, _) | a) . collect :: < Vec < _ > > ( )
35
34
}
36
35
37
- mod dist {
36
+ mod defaults {
38
37
use super :: { configure, first} ;
39
38
use crate :: builder:: * ;
39
+ use crate :: Config ;
40
40
use pretty_assertions:: assert_eq;
41
41
42
+ #[ test]
43
+ fn build_default ( ) {
44
+ let build = Build :: new ( configure ( & [ ] , & [ ] ) ) ;
45
+ let mut builder = Builder :: new ( & build) ;
46
+ builder. run_step_descriptions ( & Builder :: get_step_descriptions ( Kind :: Build ) , & [ ] ) ;
47
+
48
+ let a = TargetSelection :: from_user ( "A" ) ;
49
+ assert_eq ! (
50
+ first( builder. cache. all:: <compile:: Std >( ) ) ,
51
+ & [
52
+ compile:: Std { compiler: Compiler { host: a, stage: 0 } , target: a } ,
53
+ compile:: Std { compiler: Compiler { host: a, stage: 1 } , target: a } ,
54
+ ]
55
+ ) ;
56
+ assert ! ( !builder. cache. all:: <compile:: Assemble >( ) . is_empty( ) ) ;
57
+ // Make sure rustdoc is only built once.
58
+ assert_eq ! (
59
+ first( builder. cache. all:: <tool:: Rustdoc >( ) ) ,
60
+ // Recall that rustdoc stages are off-by-one
61
+ // - this is the compiler it's _linked_ to, not built with.
62
+ & [ tool:: Rustdoc { compiler: Compiler { host: a, stage: 1 } } ] ,
63
+ ) ;
64
+ assert_eq ! (
65
+ first( builder. cache. all:: <compile:: Rustc >( ) ) ,
66
+ & [ compile:: Rustc { compiler: Compiler { host: a, stage: 0 } , target: a } , ]
67
+ ) ;
68
+ }
69
+
70
+ #[ test]
71
+ fn build_stage_0 ( ) {
72
+ let config = Config { stage : Some ( 0 ) , ..configure ( & [ ] , & [ ] ) } ;
73
+ let build = Build :: new ( config) ;
74
+ let mut builder = Builder :: new ( & build) ;
75
+ builder. run_step_descriptions ( & Builder :: get_step_descriptions ( Kind :: Build ) , & [ ] ) ;
76
+
77
+ let a = TargetSelection :: from_user ( "A" ) ;
78
+ assert_eq ! (
79
+ first( builder. cache. all:: <compile:: Std >( ) ) ,
80
+ & [ compile:: Std { compiler: Compiler { host: a, stage: 0 } , target: a } , ]
81
+ ) ;
82
+ assert ! ( !builder. cache. all:: <compile:: Assemble >( ) . is_empty( ) ) ;
83
+ assert_eq ! (
84
+ first( builder. cache. all:: <tool:: Rustdoc >( ) ) ,
85
+ // This is the beta rustdoc.
86
+ // Add an assert here to make sure this is the only rustdoc built.
87
+ & [ tool:: Rustdoc { compiler: Compiler { host: a, stage: 0 } } ] ,
88
+ ) ;
89
+ assert ! ( builder. cache. all:: <compile:: Rustc >( ) . is_empty( ) ) ;
90
+ }
91
+
92
+ #[ test]
93
+ fn doc_default ( ) {
94
+ let mut config = configure ( & [ ] , & [ ] ) ;
95
+ config. compiler_docs = true ;
96
+ config. cmd = Subcommand :: Doc { paths : Vec :: new ( ) , open : false } ;
97
+ let build = Build :: new ( config) ;
98
+ let mut builder = Builder :: new ( & build) ;
99
+ builder. run_step_descriptions ( & Builder :: get_step_descriptions ( Kind :: Doc ) , & [ ] ) ;
100
+ let a = TargetSelection :: from_user ( "A" ) ;
101
+
102
+ // error_index_generator uses stage 0 to share rustdoc artifacts with the
103
+ // rustdoc tool.
104
+ assert_eq ! (
105
+ first( builder. cache. all:: <doc:: ErrorIndex >( ) ) ,
106
+ & [ doc:: ErrorIndex { compiler: Compiler { host: a, stage: 0 } , target: a } , ]
107
+ ) ;
108
+ assert_eq ! (
109
+ first( builder. cache. all:: <tool:: ErrorIndex >( ) ) ,
110
+ & [ tool:: ErrorIndex { compiler: Compiler { host: a, stage: 0 } } ]
111
+ ) ;
112
+ // docs should be built with the beta compiler, not with the stage0 artifacts.
113
+ // recall that rustdoc is off-by-one: `stage` is the compiler rustdoc is _linked_ to,
114
+ // not the one it was built by.
115
+ assert_eq ! (
116
+ first( builder. cache. all:: <tool:: Rustdoc >( ) ) ,
117
+ & [ tool:: Rustdoc { compiler: Compiler { host: a, stage: 0 } } , ]
118
+ ) ;
119
+ }
120
+ }
121
+
122
+ mod dist {
123
+ use super :: { first, Config } ;
124
+ use crate :: builder:: * ;
125
+ use pretty_assertions:: assert_eq;
126
+
127
+ fn configure ( host : & [ & str ] , target : & [ & str ] ) -> Config {
128
+ Config { stage : Some ( 2 ) , ..super :: configure ( host, target) }
129
+ }
130
+
42
131
#[ test]
43
132
fn dist_baseline ( ) {
44
133
let build = Build :: new ( configure ( & [ ] , & [ ] ) ) ;
@@ -276,7 +365,7 @@ mod dist {
276
365
}
277
366
278
367
#[ test]
279
- fn build_default ( ) {
368
+ fn build_all ( ) {
280
369
let build = Build :: new ( configure ( & [ "B" ] , & [ "C" ] ) ) ;
281
370
let mut builder = Builder :: new ( & build) ;
282
371
builder. run_step_descriptions (
0 commit comments