tests: produce target artifacts and/or require crate type / ignore cross-compile

Some tests fail on cross-compiled targets due to various linker problems
on cross-compiled target, and having test coverage for these against
cross-compiled targets is nice but not necessary.
This commit is contained in:
Jieyou Xu 2025-04-04 10:40:38 +08:00
parent 41931320f8
commit 4362789eb0
No known key found for this signature in database
GPG key ID: 045B995028EA6AFC
7 changed files with 41 additions and 6 deletions

View file

@ -1,9 +1,20 @@
use run_make_support::{bin_name, rust_lib_name, rustc};
use run_make_support::{bin_name, rust_lib_name, rustc, target};
fn main() {
rustc().print("crate-name").input("crate.rs").run().assert_stdout_equals("foo");
rustc().print("file-names").input("crate.rs").run().assert_stdout_equals(bin_name("foo"));
rustc()
.target(target())
.print("crate-name")
.input("crate.rs")
.run()
.assert_stdout_equals("foo");
rustc()
.target(target())
.print("file-names")
.input("crate.rs")
.run()
.assert_stdout_equals(bin_name("foo"));
rustc()
.target(target())
.print("file-names")
.crate_type("lib")
.arg("--test")
@ -11,11 +22,22 @@ fn main() {
.run()
.assert_stdout_equals(bin_name("foo"));
rustc()
.target(target())
.print("file-names")
.arg("--test")
.input("lib.rs")
.run()
.assert_stdout_equals(bin_name("mylib"));
rustc().print("file-names").input("lib.rs").run().assert_stdout_equals(rust_lib_name("mylib"));
rustc().print("file-names").input("rlib.rs").run().assert_stdout_equals(rust_lib_name("mylib"));
rustc()
.target(target())
.print("file-names")
.input("lib.rs")
.run()
.assert_stdout_equals(rust_lib_name("mylib"));
rustc()
.target(target())
.print("file-names")
.input("rlib.rs")
.run()
.assert_stdout_equals(rust_lib_name("mylib"));
}

View file

@ -4,6 +4,8 @@
// and the compiler flags, and checks that the flag is favoured each time.
// See https://github.com/rust-lang/rust/pull/15518
//@ ignore-cross-compile (relocations in generic ELF against `arm-unknown-linux-gnueabihf`)
use run_make_support::{bin_name, rfs, rustc};
fn main() {

View file

@ -6,6 +6,8 @@
// are named as expected.
// See https://github.com/rust-lang/rust/pull/15686
//@ ignore-cross-compile (relocations in generic ELF against `arm-unknown-linux-gnueabihf`)
use run_make_support::{bin_name, cwd, has_prefix, has_suffix, rfs, rustc, shallow_find_files};
fn main() {

View file

@ -4,6 +4,9 @@
// files are exactly what is expected, no more, no less.
// See https://github.com/rust-lang/rust/pull/12020
//@ ignore-cross-compile
// Reason: some cross-compiled targets don't support various crate types and fail to link.
use std::path::PathBuf;
use run_make_support::{
@ -17,6 +20,7 @@ use run_make_support::{
// `dir`: the name of the directory where the test happens
// `rustc_invocation`: the rustc command being tested
// Any unexpected output files not listed in `must_exist` or `can_exist` will cause a failure.
#[track_caller]
fn assert_expected_output_files(expectations: Expectations, rustc_invocation: impl Fn()) {
let Expectations { expected_files: must_exist, allowed_files: can_exist, test_dir: dir } =
expectations;

View file

@ -20,6 +20,8 @@
// See https://github.com/rust-lang/rust/pull/32293
// Tracking Issue: https://github.com/rust-lang/rust/issues/129080
//@ ignore-cross-compile (linker binary needs to run)
use run_make_support::{
bin_name, cwd, diff, is_darwin, is_windows, regex, rfs, run_in_tmpdir, rust_lib_name, rustc,
};

View file

@ -1,4 +1,5 @@
//@ ignore-windows Windows does not actually strip
//@ ignore-windows (Windows does not actually strip)
//@ ignore-cross-compile (relocations in generic ELF against `arm-unknown-linux-gnueabihf`)
// Test that -Cstrip correctly strips/preserves debuginfo and symbols.

View file

@ -1,5 +1,7 @@
// Check that all symbols in cdylibs, staticlibs and bins are mangled
//@ only-elf some object file formats create multiple symbols for each function with different names
//@ ignore-nvptx64 (needs target std)
//@ ignore-cross-compile (host-only)
use run_make_support::object::read::{Object, ObjectSymbol};
use run_make_support::{bin_name, dynamic_lib_name, object, rfs, rustc, static_lib_name};