Skip to content

Commit

Permalink
Add new test case 'test_std_on_unsupported_target'
Browse files Browse the repository at this point in the history
Add a new test case to check cargo handles building a target which
doesn't support the standard library properly.
  • Loading branch information
harmou01 committed Oct 30, 2024
1 parent e473534 commit 820251e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/testsuite/standard_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ trait BuildStd: Sized {
fn build_std(&mut self, setup: &Setup) -> &mut Self;
fn build_std_arg(&mut self, setup: &Setup, arg: &str) -> &mut Self;
fn target_host(&mut self) -> &mut Self;
fn target(&mut self, target: &str) -> &mut Self;
}

impl BuildStd for Execs {
Expand All @@ -183,6 +184,11 @@ impl BuildStd for Execs {
self.arg("--target").arg(rustc_host());
self
}

fn target(&mut self, target: &str) -> &mut Self {
self.arg("--target").arg(target);
self
}
}

#[cargo_test(build_std_mock)]
Expand Down Expand Up @@ -323,6 +329,31 @@ fn check_core() {
.run();
}

#[cargo_test(build_std_mock)]
fn test_std_on_unsupported_target() {
let setup = setup();

let p = project()
.file(
"src/main.rs",
r#"
fn main() {
println!("hello");
}
"#,
)
.build();

p.cargo("build")
.build_std(&setup)
.target("aarch64-unknown-none")
.with_status(101)
.with_stderr_data(str![[r#"
[ERROR] building std is not supported on this target: [..]
"#]])
.run();
}

#[cargo_test(build_std_mock)]
fn depend_same_as_std() {
let setup = setup();
Expand Down

0 comments on commit 820251e

Please sign in to comment.