From 6a980bca738923c9cee99f211fd2123858a7d44f Mon Sep 17 00:00:00 2001 From: Harry Moulton Date: Fri, 31 May 2024 15:44:23 +0100 Subject: [PATCH] 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. --- tests/testsuite/standard_lib.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/testsuite/standard_lib.rs b/tests/testsuite/standard_lib.rs index 08d371e2fdb..7c3eb35f1af 100644 --- a/tests/testsuite/standard_lib.rs +++ b/tests/testsuite/standard_lib.rs @@ -323,6 +323,32 @@ 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") + .arg("--target=aarch64-unknown-none") + .arg("--target=x86_64-unknown-none") + .build_std(&setup) + .with_status(101) + .with_stderr_data(str![[r#" +[ERROR] building std is not supported on the following targets: [..] +"#]]) + .run(); +} + #[cargo_test(build_std_mock)] fn depend_same_as_std() { let setup = setup();