Skip to content

Commit b7b55ec

Browse files
committed
Add new test case 'test_std_on_unsupported_target'
Add a new test case to check cargo handles building a target which doesn't support the standard library properly.
1 parent e93004f commit b7b55ec

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/testsuite/standard_lib.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ trait BuildStd: Sized {
164164
fn build_std(&mut self, setup: &Setup) -> &mut Self;
165165
fn build_std_arg(&mut self, setup: &Setup, arg: &str) -> &mut Self;
166166
fn target_host(&mut self) -> &mut Self;
167+
fn target(&mut self, target: &str) -> &mut Self;
167168
}
168169

169170
impl BuildStd for Execs {
@@ -183,6 +184,11 @@ impl BuildStd for Execs {
183184
self.arg("--target").arg(rustc_host());
184185
self
185186
}
187+
188+
fn target(&mut self, target: &str) -> &mut Self {
189+
self.arg("--target").arg(target);
190+
self
191+
}
186192
}
187193

188194
#[cargo_test(build_std_mock)]
@@ -323,6 +329,33 @@ fn check_core() {
323329
.run();
324330
}
325331

332+
#[cargo_test(build_std_mock)]
333+
fn test_std_on_unsupported_target() {
334+
let setup = setup();
335+
336+
let p = project()
337+
.file(
338+
"src/main.rs",
339+
r#"
340+
fn main() {
341+
println!("hello");
342+
}
343+
"#,
344+
)
345+
.build();
346+
347+
p.cargo("build")
348+
.build_std(&setup)
349+
.target("aarch64-unknown-none")
350+
.with_status(101)
351+
.with_stderr_data(
352+
"\
353+
[ERROR] building std is not supported on this target: [..]
354+
",
355+
)
356+
.run();
357+
}
358+
326359
#[cargo_test(build_std_mock)]
327360
fn depend_same_as_std() {
328361
let setup = setup();

0 commit comments

Comments
 (0)