This commit is contained in:
2026-09-17 16:27:34 +02:00
parent a7cd4244b2
commit 775e3d3b8a
5 changed files with 31 additions and 32 deletions
+14 -8
View File
@@ -212,8 +212,10 @@ pub fn run_source_build(
) -> Result<SourceBuildOutput, Box<dyn Error>> { ) -> Result<SourceBuildOutput, Box<dyn Error>> {
// Without a live UI, test runs still capture command output into the // Without a live UI, test runs still capture command output into the
// per-test log file instead of letting it inherit the terminal // per-test log file instead of letting it inherit the terminal
let sink: Option<Arc<dyn LineSink>> = let sink: Option<Arc<dyn LineSink>> = ui
ui.as_ref().map(|u| u.sink()).or_else(crate::test_support::subprocess_sink); .as_ref()
.map(|u| u.sink())
.or_else(crate::test_support::subprocess_sink);
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// 1. Sanity checks // 1. Sanity checks
// ------------------------------------------------------------------ // ------------------------------------------------------------------
@@ -1315,9 +1317,8 @@ mod differential_tests {
} }
fn copy_path(src: &Path, dst_root: &Path) { fn copy_path(src: &Path, dst_root: &Path) {
let status = crate::test_support::run_logged( let status =
Command::new("cp").arg("-a").arg(src).arg(dst_root), crate::test_support::run_logged(Command::new("cp").arg("-a").arg(src).arg(dst_root))
)
.expect("run cp -a"); .expect("run cp -a");
assert!( assert!(
status.success(), status.success(),
@@ -1329,9 +1330,14 @@ mod differential_tests {
fn run_dpkg(tree: &Path) { fn run_dpkg(tree: &Path) {
let status = crate::test_support::run_logged( let status = crate::test_support::run_logged(
Command::new("dpkg-buildpackage") Command::new("dpkg-buildpackage").current_dir(tree).args([
.current_dir(tree) "-S",
.args(["-S", "-I", "-i", "-nc", "-d", "--no-sign"]), "-I",
"-i",
"-nc",
"-d",
"--no-sign",
]),
) )
.expect("failed to run dpkg-buildpackage (is dpkg-dev installed?)"); .expect("failed to run dpkg-buildpackage (is dpkg-dev installed?)");
assert!(status.success(), "dpkg-buildpackage failed"); assert!(status.success(), "dpkg-buildpackage failed");
+9 -10
View File
@@ -645,7 +645,8 @@ async fn fetch_index_bytes(url: &str) -> Result<Vec<u8>, String> {
Err(e) => { Err(e) => {
last_error = e.to_string(); last_error = e.to_string();
log::debug!("fetch of '{url}' failed (attempt {attempt}/{ATTEMPTS}): {last_error}"); log::debug!("fetch of '{url}' failed (attempt {attempt}/{ATTEMPTS}): {last_error}");
tokio::time::sleep(std::time::Duration::from_millis(300 * u64::from(attempt))).await; tokio::time::sleep(std::time::Duration::from_millis(300 * u64::from(attempt)))
.await;
} }
Ok(response) => { Ok(response) => {
if !response.status().is_success() { if !response.status().is_success() {
@@ -659,9 +660,9 @@ async fn fetch_index_bytes(url: &str) -> Result<Vec<u8>, String> {
log::debug!( log::debug!(
"empty body for '{url}' (attempt {attempt}/{ATTEMPTS}), retrying" "empty body for '{url}' (attempt {attempt}/{ATTEMPTS}), retrying"
); );
tokio::time::sleep( tokio::time::sleep(std::time::Duration::from_millis(
std::time::Duration::from_millis(300 * u64::from(attempt)), 300 * u64::from(attempt),
) ))
.await; .await;
} }
Ok(bytes) => return Ok(bytes.to_vec()), Ok(bytes) => return Ok(bytes.to_vec()),
@@ -671,9 +672,9 @@ async fn fetch_index_bytes(url: &str) -> Result<Vec<u8>, String> {
log::debug!( log::debug!(
"reading the body of '{url}' failed (attempt {attempt}/{ATTEMPTS}): {last_error}" "reading the body of '{url}' failed (attempt {attempt}/{ATTEMPTS}): {last_error}"
); );
tokio::time::sleep( tokio::time::sleep(std::time::Duration::from_millis(
std::time::Duration::from_millis(300 * u64::from(attempt)), 300 * u64::from(attempt),
) ))
.await; .await;
} }
} }
@@ -952,10 +953,8 @@ mod tests {
let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap(); let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
let addr = listener.local_addr().unwrap(); let addr = listener.local_addr().unwrap();
std::thread::spawn(move || { std::thread::spawn(move || {
let mut served = 0usize; for (served, stream) in listener.incoming().flatten().enumerate() {
for stream in listener.incoming().flatten() {
let index = served.min(responses.len() - 1); let index = served.min(responses.len() - 1);
served += 1;
let mut stream = stream; let mut stream = stream;
// Drain the request first: closing with unread inbound data // Drain the request first: closing with unread inbound data
// would send a TCP RST and destroy the response in flight // would send a TCP RST and destroy the response in flight
+4 -8
View File
@@ -320,18 +320,14 @@ async fn download_file_checksum(
match download_file_checksum_once(url, checksum, algo, target_dir, progress).await { match download_file_checksum_once(url, checksum, algo, target_dir, progress).await {
Ok(()) => return Ok(()), Ok(()) => return Ok(()),
Err(e) => { Err(e) => {
log::warn!( log::warn!("download of '{url}' failed (attempt {attempt}/{ATTEMPTS}): {e}");
"download of '{url}' failed (attempt {attempt}/{ATTEMPTS}): {e}"
);
last_error = e; last_error = e;
tokio::time::sleep(std::time::Duration::from_millis(500 * u64::from(attempt))).await; tokio::time::sleep(std::time::Duration::from_millis(500 * u64::from(attempt)))
.await;
} }
} }
} }
Err(format!( Err(format!("downloading '{url}' failed after {ATTEMPTS} attempts: {last_error}").into())
"downloading '{url}' failed after {ATTEMPTS} attempts: {last_error}"
)
.into())
} }
/// One download attempt of [`download_file_checksum`], verifying the /// One download attempt of [`download_file_checksum`], verifying the
+2 -2
View File
@@ -65,6 +65,8 @@ mod imp {
pub(crate) struct SuppressFailuresStub; pub(crate) struct SuppressFailuresStub;
} }
pub(crate) use imp::*;
#[cfg(test)] #[cfg(test)]
mod imp { mod imp {
use std::collections::HashMap; use std::collections::HashMap;
@@ -482,5 +484,3 @@ mod imp {
.unwrap_or_else(|| "<current>".to_string()) .unwrap_or_else(|| "<current>".to_string())
} }
} }
pub(crate) use imp::*;
+1 -3
View File
@@ -9,11 +9,9 @@ pub mod logfmt;
/// yes/no confirmation /// yes/no confirmation
pub mod prompt; pub mod prompt;
use indicatif::{
MultiProgress, ProgressBar, ProgressStyle,
};
#[cfg(test)] #[cfg(test)]
use indicatif::ProgressDrawTarget; use indicatif::ProgressDrawTarget;
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
use std::path::Path; use std::path::Path;
use std::time::Duration; use std::time::Duration;