2 use crate::config
::Config
;
5 use pretty_assertions
::assert_eq
;
7 fn configure(host
: &[&str], target
: &[&str]) -> Config
{
8 let mut config
= Config
::default_opts();
9 // don't save toolstates
10 config
.save_toolstates
= None
;
11 config
.skip_only_host_steps
= false;
12 config
.dry_run
= true;
13 // try to avoid spurious failures in dist where we create/delete each others file
14 let dir
= config
.out
.join("tmp-rustbuild-tests").join(
20 t
!(fs
::create_dir_all(&dir
));
22 config
.build
= INTERNER
.intern_str("A");
23 config
.hosts
= vec
![config
.build
]
26 .chain(host
.iter().map(|s
| INTERNER
.intern_str(s
)))
28 config
.targets
= config
32 .chain(target
.iter().map(|s
| INTERNER
.intern_str(s
)))
37 fn first
<A
, B
>(v
: Vec
<(A
, B
)>) -> Vec
<A
> {
38 v
.into_iter().map(|(a
, _
)| a
).collect
::<Vec
<_
>>()
43 let build
= Build
::new(configure(&[], &[]));
44 let mut builder
= Builder
::new(&build
);
45 builder
.run_step_descriptions(&Builder
::get_step_descriptions(Kind
::Dist
), &[]);
47 let a
= INTERNER
.intern_str("A");
50 first(builder
.cache
.all
::<dist
::Docs
>()),
51 &[dist
::Docs { host: a }
,]
54 first(builder
.cache
.all
::<dist
::Mingw
>()),
55 &[dist
::Mingw { host: a }
,]
58 first(builder
.cache
.all
::<dist
::Rustc
>()),
60 compiler
: Compiler { host: a, stage: 2 }
64 first(builder
.cache
.all
::<dist
::Std
>()),
66 compiler
: Compiler { host: a, stage: 1 }
,
70 assert_eq
!(first(builder
.cache
.all
::<dist
::Src
>()), &[dist
::Src
]);
74 fn dist_with_targets() {
75 let build
= Build
::new(configure(&[], &["B"]));
76 let mut builder
= Builder
::new(&build
);
77 builder
.run_step_descriptions(&Builder
::get_step_descriptions(Kind
::Dist
), &[]);
79 let a
= INTERNER
.intern_str("A");
80 let b
= INTERNER
.intern_str("B");
83 first(builder
.cache
.all
::<dist
::Docs
>()),
85 dist
::Docs { host: a }
,
86 dist
::Docs { host: b }
,
90 first(builder
.cache
.all
::<dist
::Mingw
>()),
91 &[dist
::Mingw { host: a }
, dist
::Mingw { host: b }
,]
94 first(builder
.cache
.all
::<dist
::Rustc
>()),
96 compiler
: Compiler { host: a, stage: 2 }
100 first(builder
.cache
.all
::<dist
::Std
>()),
103 compiler
: Compiler { host: a, stage: 1 }
,
107 compiler
: Compiler { host: a, stage: 2 }
,
112 assert_eq
!(first(builder
.cache
.all
::<dist
::Src
>()), &[dist
::Src
]);
116 fn dist_with_hosts() {
117 let build
= Build
::new(configure(&["B"], &[]));
118 let mut builder
= Builder
::new(&build
);
119 builder
.run_step_descriptions(&Builder
::get_step_descriptions(Kind
::Dist
), &[]);
121 let a
= INTERNER
.intern_str("A");
122 let b
= INTERNER
.intern_str("B");
125 first(builder
.cache
.all
::<dist
::Docs
>()),
127 dist
::Docs { host: a }
,
128 dist
::Docs { host: b }
,
132 first(builder
.cache
.all
::<dist
::Mingw
>()),
133 &[dist
::Mingw { host: a }
, dist
::Mingw { host: b }
,]
136 first(builder
.cache
.all
::<dist
::Rustc
>()),
139 compiler
: Compiler { host: a, stage: 2 }
142 compiler
: Compiler { host: b, stage: 2 }
147 first(builder
.cache
.all
::<dist
::Std
>()),
150 compiler
: Compiler { host: a, stage: 1 }
,
154 compiler
: Compiler { host: a, stage: 1 }
,
159 assert_eq
!(first(builder
.cache
.all
::<dist
::Src
>()), &[dist
::Src
]);
163 fn dist_only_cross_host() {
164 let a
= INTERNER
.intern_str("A");
165 let b
= INTERNER
.intern_str("B");
166 let mut build
= Build
::new(configure(&["B"], &[]));
167 build
.config
.docs
= false;
168 build
.config
.extended
= true;
169 build
.hosts
= vec
![b
];
170 let mut builder
= Builder
::new(&build
);
171 builder
.run_step_descriptions(&Builder
::get_step_descriptions(Kind
::Dist
), &[]);
174 first(builder
.cache
.all
::<dist
::Rustc
>()),
177 compiler
: Compiler { host: b, stage: 2 }
182 first(builder
.cache
.all
::<compile
::Rustc
>()),
185 compiler
: Compiler { host: a, stage: 0 }
,
189 compiler
: Compiler { host: a, stage: 1 }
,
197 fn dist_with_targets_and_hosts() {
198 let build
= Build
::new(configure(&["B"], &["C"]));
199 let mut builder
= Builder
::new(&build
);
200 builder
.run_step_descriptions(&Builder
::get_step_descriptions(Kind
::Dist
), &[]);
202 let a
= INTERNER
.intern_str("A");
203 let b
= INTERNER
.intern_str("B");
204 let c
= INTERNER
.intern_str("C");
207 first(builder
.cache
.all
::<dist
::Docs
>()),
209 dist
::Docs { host: a }
,
210 dist
::Docs { host: b }
,
211 dist
::Docs { host: c }
,
215 first(builder
.cache
.all
::<dist
::Mingw
>()),
217 dist
::Mingw { host: a }
,
218 dist
::Mingw { host: b }
,
219 dist
::Mingw { host: c }
,
223 first(builder
.cache
.all
::<dist
::Rustc
>()),
226 compiler
: Compiler { host: a, stage: 2 }
229 compiler
: Compiler { host: b, stage: 2 }
234 first(builder
.cache
.all
::<dist
::Std
>()),
237 compiler
: Compiler { host: a, stage: 1 }
,
241 compiler
: Compiler { host: a, stage: 1 }
,
245 compiler
: Compiler { host: a, stage: 2 }
,
250 assert_eq
!(first(builder
.cache
.all
::<dist
::Src
>()), &[dist
::Src
]);
254 fn dist_with_target_flag() {
255 let mut config
= configure(&["B"], &["C"]);
256 config
.skip_only_host_steps
= true; // as-if --target=C was passed
257 let build
= Build
::new(config
);
258 let mut builder
= Builder
::new(&build
);
259 builder
.run_step_descriptions(&Builder
::get_step_descriptions(Kind
::Dist
), &[]);
261 let a
= INTERNER
.intern_str("A");
262 let b
= INTERNER
.intern_str("B");
263 let c
= INTERNER
.intern_str("C");
266 first(builder
.cache
.all
::<dist
::Docs
>()),
268 dist
::Docs { host: a }
,
269 dist
::Docs { host: b }
,
270 dist
::Docs { host: c }
,
274 first(builder
.cache
.all
::<dist
::Mingw
>()),
276 dist
::Mingw { host: a }
,
277 dist
::Mingw { host: b }
,
278 dist
::Mingw { host: c }
,
281 assert_eq
!(first(builder
.cache
.all
::<dist
::Rustc
>()), &[]);
283 first(builder
.cache
.all
::<dist
::Std
>()),
286 compiler
: Compiler { host: a, stage: 1 }
,
290 compiler
: Compiler { host: a, stage: 1 }
,
294 compiler
: Compiler { host: a, stage: 2 }
,
299 assert_eq
!(first(builder
.cache
.all
::<dist
::Src
>()), &[]);
303 fn dist_with_same_targets_and_hosts() {
304 let build
= Build
::new(configure(&["B"], &["B"]));
305 let mut builder
= Builder
::new(&build
);
306 builder
.run_step_descriptions(&Builder
::get_step_descriptions(Kind
::Dist
), &[]);
308 let a
= INTERNER
.intern_str("A");
309 let b
= INTERNER
.intern_str("B");
312 first(builder
.cache
.all
::<dist
::Docs
>()),
314 dist
::Docs { host: a }
,
315 dist
::Docs { host: b }
,
319 first(builder
.cache
.all
::<dist
::Mingw
>()),
320 &[dist
::Mingw { host: a }
, dist
::Mingw { host: b }
,]
323 first(builder
.cache
.all
::<dist
::Rustc
>()),
326 compiler
: Compiler { host: a, stage: 2 }
329 compiler
: Compiler { host: b, stage: 2 }
334 first(builder
.cache
.all
::<dist
::Std
>()),
337 compiler
: Compiler { host: a, stage: 1 }
,
341 compiler
: Compiler { host: a, stage: 1 }
,
346 assert_eq
!(first(builder
.cache
.all
::<dist
::Src
>()), &[dist
::Src
]);
348 first(builder
.cache
.all
::<compile
::Std
>()),
351 compiler
: Compiler { host: a, stage: 0 }
,
355 compiler
: Compiler { host: a, stage: 1 }
,
359 compiler
: Compiler { host: a, stage: 2 }
,
363 compiler
: Compiler { host: a, stage: 1 }
,
369 first(builder
.cache
.all
::<compile
::Test
>()),
372 compiler
: Compiler { host: a, stage: 0 }
,
376 compiler
: Compiler { host: a, stage: 1 }
,
380 compiler
: Compiler { host: a, stage: 2 }
,
384 compiler
: Compiler { host: a, stage: 1 }
,
390 first(builder
.cache
.all
::<compile
::Assemble
>()),
393 target_compiler
: Compiler { host: a, stage: 0 }
,
396 target_compiler
: Compiler { host: a, stage: 1 }
,
399 target_compiler
: Compiler { host: a, stage: 2 }
,
402 target_compiler
: Compiler { host: b, stage: 2 }
,
410 let build
= Build
::new(configure(&["B"], &["C"]));
411 let mut builder
= Builder
::new(&build
);
412 builder
.run_step_descriptions(&Builder
::get_step_descriptions(Kind
::Build
), &[]);
414 let a
= INTERNER
.intern_str("A");
415 let b
= INTERNER
.intern_str("B");
416 let c
= INTERNER
.intern_str("C");
418 assert
!(!builder
.cache
.all
::<compile
::Std
>().is_empty());
419 assert
!(!builder
.cache
.all
::<compile
::Assemble
>().is_empty());
421 first(builder
.cache
.all
::<compile
::Rustc
>()),
424 compiler
: Compiler { host: a, stage: 0 }
,
428 compiler
: Compiler { host: a, stage: 1 }
,
432 compiler
: Compiler { host: a, stage: 2 }
,
436 compiler
: Compiler { host: b, stage: 2 }
,
440 compiler
: Compiler { host: a, stage: 1 }
,
444 compiler
: Compiler { host: a, stage: 2 }
,
448 compiler
: Compiler { host: b, stage: 2 }
,
455 first(builder
.cache
.all
::<compile
::Test
>()),
458 compiler
: Compiler { host: a, stage: 0 }
,
462 compiler
: Compiler { host: a, stage: 1 }
,
466 compiler
: Compiler { host: a, stage: 2 }
,
470 compiler
: Compiler { host: b, stage: 2 }
,
474 compiler
: Compiler { host: a, stage: 1 }
,
478 compiler
: Compiler { host: a, stage: 2 }
,
482 compiler
: Compiler { host: b, stage: 2 }
,
486 compiler
: Compiler { host: a, stage: 2 }
,
490 compiler
: Compiler { host: b, stage: 2 }
,
498 fn build_with_target_flag() {
499 let mut config
= configure(&["B"], &["C"]);
500 config
.skip_only_host_steps
= true;
501 let build
= Build
::new(config
);
502 let mut builder
= Builder
::new(&build
);
503 builder
.run_step_descriptions(&Builder
::get_step_descriptions(Kind
::Build
), &[]);
505 let a
= INTERNER
.intern_str("A");
506 let b
= INTERNER
.intern_str("B");
507 let c
= INTERNER
.intern_str("C");
509 assert
!(!builder
.cache
.all
::<compile
::Std
>().is_empty());
511 first(builder
.cache
.all
::<compile
::Assemble
>()),
514 target_compiler
: Compiler { host: a, stage: 0 }
,
517 target_compiler
: Compiler { host: a, stage: 1 }
,
520 target_compiler
: Compiler { host: a, stage: 2 }
,
523 target_compiler
: Compiler { host: b, stage: 2 }
,
528 first(builder
.cache
.all
::<compile
::Rustc
>()),
531 compiler
: Compiler { host: a, stage: 0 }
,
535 compiler
: Compiler { host: a, stage: 1 }
,
539 compiler
: Compiler { host: a, stage: 1 }
,
546 first(builder
.cache
.all
::<compile
::Test
>()),
549 compiler
: Compiler { host: a, stage: 0 }
,
553 compiler
: Compiler { host: a, stage: 1 }
,
557 compiler
: Compiler { host: a, stage: 2 }
,
561 compiler
: Compiler { host: b, stage: 2 }
,
565 compiler
: Compiler { host: a, stage: 1 }
,
569 compiler
: Compiler { host: a, stage: 2 }
,
573 compiler
: Compiler { host: b, stage: 2 }
,
577 compiler
: Compiler { host: a, stage: 2 }
,
581 compiler
: Compiler { host: b, stage: 2 }
,
589 fn test_with_no_doc_stage0() {
590 let mut config
= configure(&[], &[]);
591 config
.stage
= Some(0);
592 config
.cmd
= Subcommand
::Test
{
593 paths
: vec
!["src/libstd".into()],
597 doc_tests
: DocTests
::No
,
600 rustfix_coverage
: false,
604 let build
= Build
::new(config
);
605 let mut builder
= Builder
::new(&build
);
607 let host
= INTERNER
.intern_str("A");
609 builder
.run_step_descriptions(
610 &[StepDescription
::from
::<test
::Crate
>()],
611 &["src/libstd".into()],
614 // Ensure we don't build any compiler artifacts.
615 assert
!(!builder
.cache
.contains
::<compile
::Rustc
>());
617 first(builder
.cache
.all
::<test
::Crate
>()),
619 compiler
: Compiler { host, stage: 0 }
,
622 test_kind
: test
::TestKind
::Test
,
623 krate
: INTERNER
.intern_str("std"),
630 let mut config
= configure(&[], &[]);
631 config
.exclude
= vec
![
632 "src/tools/tidy".into(),
634 config
.cmd
= Subcommand
::Test
{
636 test_args
: Vec
::new(),
637 rustc_args
: Vec
::new(),
639 doc_tests
: DocTests
::No
,
642 rustfix_coverage
: false,
646 let build
= Build
::new(config
);
647 let builder
= Builder
::new(&build
);
648 builder
.run_step_descriptions(&Builder
::get_step_descriptions(Kind
::Test
), &[]);
650 // Ensure we have really excluded tidy
651 assert
!(!builder
.cache
.contains
::<test
::Tidy
>());
653 // Ensure other tests are not affected.
654 assert
!(builder
.cache
.contains
::<test
::RustdocUi
>());