Skip to content

Commit 2e97e9f

Browse files
committed
extend test coverage for std build
Signed-off-by: onur-ozkan <[email protected]>
1 parent 03d9ec2 commit 2e97e9f

File tree

2 files changed

+53
-14
lines changed

2 files changed

+53
-14
lines changed

Diff for: src/bootstrap/src/core/build_steps/compile.rs

+6
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ impl Std {
111111
}
112112
deps
113113
}
114+
115+
#[cfg(feature = "bootstrap-self-test")]
116+
pub fn crates(mut self, crates: Vec<String>) -> Self {
117+
self.crates = crates;
118+
self
119+
}
114120
}
115121

116122
impl Step for Std {

Diff for: src/bootstrap/src/core/builder/tests.rs

+47-14
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ fn first<A, B>(v: Vec<(A, B)>) -> Vec<A> {
4242
v.into_iter().map(|(a, _)| a).collect::<Vec<_>>()
4343
}
4444

45-
fn run_build(paths: &[PathBuf], config: Config) -> Cache {
45+
fn run_build(paths: &[PathBuf], mut config: Config) -> Cache {
46+
config.paths.extend(paths.to_vec());
4647
let kind = config.cmd.kind();
4748
let build = Build::new(config);
4849
let builder = Builder::new(&build);
@@ -58,18 +59,32 @@ fn check_cli<const N: usize>(paths: [&str; N]) {
5859
}
5960

6061
macro_rules! std {
61-
($host:ident => $target:ident, stage = $stage:literal) => {
62-
compile::Std::new(
63-
Compiler {
64-
host: TargetSelection::from_user(concat!(
65-
stringify!($host),
66-
"-",
67-
stringify!($host)
68-
)),
69-
stage: $stage,
70-
},
71-
TargetSelection::from_user(concat!(stringify!($target), "-", stringify!($target))),
72-
)
62+
($host:ident => $target:ident, stage = $stage:literal $(,force_recompile = $force_recompile:literal)?) => {
63+
if false $(|| $force_recompile)? {
64+
compile::Std::force_recompile(
65+
Compiler {
66+
host: TargetSelection::from_user(concat!(
67+
stringify!($host),
68+
"-",
69+
stringify!($host)
70+
)),
71+
stage: $stage,
72+
},
73+
TargetSelection::from_user(concat!(stringify!($target), "-", stringify!($target))),
74+
)
75+
} else {
76+
compile::Std::new(
77+
Compiler {
78+
host: TargetSelection::from_user(concat!(
79+
stringify!($host),
80+
"-",
81+
stringify!($host)
82+
)),
83+
stage: $stage,
84+
},
85+
TargetSelection::from_user(concat!(stringify!($target), "-", stringify!($target))),
86+
)
87+
}
7388
};
7489
}
7590

@@ -203,7 +218,25 @@ fn alias_and_path_for_library() {
203218
run_build(&["library".into(), "core".into()], configure("build", &["A-A"], &["A-A"]));
204219
assert_eq!(
205220
first(cache.all::<compile::Std>()),
206-
&[std!(A => A, stage = 0), std!(A => A, stage = 1)]
221+
&[std!(A => A, stage = 0), std!(A => A, stage = 1, force_recompile = true)]
222+
);
223+
224+
let mut cache =
225+
run_build(&["library".into(), "core".into()], configure("doc", &["A-A"], &["A-A"]));
226+
assert_eq!(first(cache.all::<doc::Std>()), &[doc_std!(A => A, stage = 0)]);
227+
}
228+
229+
#[test]
230+
fn std_with_crates_and_force_recompile() {
231+
let mut cache =
232+
run_build(&["std".into(), "alloc".into()], configure("build", &["A-A"], &["A-A"]));
233+
assert_eq!(
234+
first(cache.all::<compile::Std>()),
235+
&[
236+
std!(A => A, stage = 0),
237+
std!(A => A, stage = 1, force_recompile = true)
238+
.crates(vec!["alloc".into(), "std".into()])
239+
]
207240
);
208241

209242
let mut cache =

0 commit comments

Comments
 (0)