Skip to content

Commit 519f069

Browse files
authored
test(build-std): make mock-std closer to real world (#14896)
### What does this PR try to resolve? `test_std_on_unsupported_target` never really succeed to build those targets, due to * local rustup may not have `{aarch64,x86_64}-unknown-none` installed. * `core` and `compiler-builtins` mock crate are not `no_std` nor `no_core` * the dummy `main.rs` uses `println!` and is not `no_std`. This commit make it compile, if you have those targets installed. ### How should we test and review this PR? Change this line to `.build_std_arg(&setup, "core")`. https://github.com/rust-lang/cargo/blob/05f54fdc34310f458033af8a63ce1d699fae8bf6/tests/testsuite/standard_lib.rs?plain=1#L410 And delete these liens: https://github.com/rust-lang/cargo/blob/05f54fdc34310f458033af8a63ce1d699fae8bf6/src/cargo/core/compiler/standard_lib.rs?plain=1#L75-L84 Then the test project should compile.
2 parents 05f54fd + fbb5b90 commit 519f069

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
// intentionally blank
1+
#![no_std]

tests/testsuite/mock-std/library/core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![no_std]
12
#![feature(staged_api)]
23
#![stable(since = "1.0.0", feature = "dummy")]
34

tests/testsuite/standard_lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,13 @@ fn test_std_on_unsupported_target() {
395395

396396
let p = project()
397397
.file(
398-
"src/main.rs",
398+
"src/lib.rs",
399399
r#"
400-
fn main() {
401-
println!("hello");
402-
}
403-
"#,
400+
#![no_std]
401+
pub fn foo() {
402+
assert_eq!(u8::MIN, 0);
403+
}
404+
"#,
404405
)
405406
.build();
406407

0 commit comments

Comments
 (0)