Skip to content

Commit c09ba9c

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 478399a commit c09ba9c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/testsuite/standard_lib.rs

+33
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ trait BuildStd: Sized {
162162
fn build_std(&mut self, setup: &Setup) -> &mut Self;
163163
fn build_std_arg(&mut self, setup: &Setup, arg: &str) -> &mut Self;
164164
fn target_host(&mut self) -> &mut Self;
165+
fn target(&mut self, target: &str) -> &mut Self;
165166
}
166167

167168
impl BuildStd for Execs {
@@ -181,6 +182,11 @@ impl BuildStd for Execs {
181182
self.arg("--target").arg(rustc_host());
182183
self
183184
}
185+
186+
fn target(&mut self, target: &str) -> &mut Self {
187+
self.arg("--target").arg(target);
188+
self
189+
}
184190
}
185191

186192
#[cargo_test(build_std_mock)]
@@ -321,6 +327,33 @@ fn check_core() {
321327
.run();
322328
}
323329

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

0 commit comments

Comments
 (0)