Auto merge of #149419 - matthiaskrgr:rollup-v3q93fq, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#147952 (Add a timeout to the `remote-test-client` connection)
 - rust-lang/rust#149321 (Fix ICE when include_str! reads binary files)
 - rust-lang/rust#149398 (add regression test for issue rust-lang/rust#143987)
 - rust-lang/rust#149411 (Tidying up UI tests [5/N])
 - rust-lang/rust#149413 (add test for issue 143821)
 - rust-lang/rust#149415 (Remove test-float-parse from workspace list in tidy)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors
2025-11-28 17:26:31 +00:00
46 changed files with 258 additions and 151 deletions
@@ -321,6 +321,10 @@ Tests are built on the machine running `x` not on the remote machine.
Tests which fail to build unexpectedly (or `ui` tests producing incorrect build
output) may fail without ever running on the remote machine.
There is a default timeout of 30 minutes in case the `remote-test-server`
cannot be reached by the `x` command. This timeout can be modified by using the
`TEST_DEVICE_CONNECT_TIMEOUT_SECONDS` environment variable.
## Testing on emulators
Some platforms are tested via an emulator for architectures that aren't readily available.
+25 -2
View File
@@ -11,12 +11,16 @@
use std::net::TcpStream;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::time::Duration;
use std::time::{Duration, Instant};
use std::{env, thread};
const REMOTE_ADDR_ENV: &str = "TEST_DEVICE_ADDR";
const DEFAULT_ADDR: &str = "127.0.0.1:12345";
const CONNECT_TIMEOUT_ENV: &str = "TEST_DEVICE_CONNECT_TIMEOUT_SECONDS";
/// The default timeout is high to not break slow CI or slow device starts.
const DEFAULT_CONNECT_TIMEOUT: Duration = Duration::from_mins(30);
macro_rules! t {
($e:expr) => {
match $e {
@@ -56,6 +60,17 @@ fn main() {
}
}
fn connect_timeout() -> Duration {
match env::var(CONNECT_TIMEOUT_ENV).ok() {
Some(timeout) => timeout.parse().map(Duration::from_secs).unwrap_or_else(|e| {
panic!(
"error: parsing `{CONNECT_TIMEOUT_ENV}` value \"{timeout}\" as seconds failed: {e}"
)
}),
None => DEFAULT_CONNECT_TIMEOUT,
}
}
fn spawn_emulator(target: &str, server: &Path, tmpdir: &Path, rootfs: Option<PathBuf>) {
let device_address = env::var(REMOTE_ADDR_ENV).unwrap_or(DEFAULT_ADDR.to_string());
@@ -69,7 +84,10 @@ fn spawn_emulator(target: &str, server: &Path, tmpdir: &Path, rootfs: Option<Pat
}
// Wait for the emulator to come online
loop {
let timeout = connect_timeout();
let mut successful_read = false;
let start_time = Instant::now();
while start_time.elapsed() < timeout {
let dur = Duration::from_millis(2000);
if let Ok(mut client) = TcpStream::connect(&device_address) {
t!(client.set_read_timeout(Some(dur)));
@@ -77,12 +95,17 @@ fn spawn_emulator(target: &str, server: &Path, tmpdir: &Path, rootfs: Option<Pat
if client.write_all(b"ping").is_ok() {
let mut b = [0; 4];
if client.read_exact(&mut b).is_ok() {
successful_read = true;
break;
}
}
}
thread::sleep(dur);
}
if !successful_read {
panic!("Gave up trying to connect to test device at {device_address} after {timeout:?}");
}
}
fn start_android_emulator(server: &Path) {
+15
View File
@@ -8,3 +8,18 @@ fn test_help() {
let stdout = String::from_utf8(output.stdout.clone()).unwrap();
assert!(stdout.trim().starts_with("Usage:"));
}
#[test]
fn test_timeout() {
let mut cmd = assert_cmd::cargo::cargo_bin_cmd!();
cmd.env("TEST_DEVICE_CONNECT_TIMEOUT_SECONDS", "1");
cmd.env("TEST_DEVICE_ADDR", "127.69.69.69:6969");
cmd.args(["spawn-emulator", "dummy-target", "dummy-server", "dummy-tmpdir"]);
let assert = cmd.assert().failure();
let output = assert.get_output();
let stderr = String::from_utf8(output.stderr.clone()).unwrap();
let pass_msg = "Gave up trying to connect to test device";
assert!(stderr.contains(pass_msg), "Could not find `{pass_msg}` in `{stderr}`");
}
-6
View File
@@ -168,12 +168,6 @@ pub(crate) struct WorkspaceInfo<'a> {
crates_and_deps: None,
submodules: &["src/tools/rustc-perf"],
},
WorkspaceInfo {
path: "src/tools/test-float-parse",
exceptions: EXCEPTIONS,
crates_and_deps: None,
submodules: &[],
},
WorkspaceInfo {
path: "tests/run-make-cargo/uefi-qemu/uefi_qemu_test",
exceptions: EXCEPTIONS_UEFI_QEMU_TEST,
+1
View File
@@ -157,6 +157,7 @@ fn check_unexpected_extension(check: &mut RunningCheck, file_path: &Path, ext: &
"tests/ui/crate-loading/auxiliary/libfoo.rlib", // testing loading a manually created rlib
"tests/ui/include-macros/data.bin", // testing including data with the include macros
"tests/ui/include-macros/file.txt", // testing including data with the include macros
"tests/ui/include-macros/invalid-utf8-binary-file.bin", // testing including data with the include macros
"tests/ui/macros/macro-expanded-include/file.txt", // testing including data with the include macros
"tests/ui/macros/not-utf8.bin", // testing including data with the include macros
"tests/ui/macros/syntax-extension-source-utils-files/includeme.fragment", // more include