don't even try to compare with reference when there was truncation

This commit is contained in:
Ralf Jung 2023-09-09 15:15:26 +02:00
parent ef46066271
commit 9cf27980da
2 changed files with 43 additions and 7 deletions

View File

@ -9,7 +9,16 @@
use std::mem::replace; use std::mem::replace;
use std::process::{Child, Output}; use std::process::{Child, Output};
pub fn read2_abbreviated(mut child: Child, filter_paths_from_len: &[String]) -> io::Result<Output> { #[derive(Copy, Clone, Debug)]
pub enum Truncated {
Yes,
No,
}
pub fn read2_abbreviated(
mut child: Child,
filter_paths_from_len: &[String],
) -> io::Result<(Output, Truncated)> {
let mut stdout = ProcOutput::new(); let mut stdout = ProcOutput::new();
let mut stderr = ProcOutput::new(); let mut stderr = ProcOutput::new();
@ -24,7 +33,9 @@ pub fn read2_abbreviated(mut child: Child, filter_paths_from_len: &[String]) ->
)?; )?;
let status = child.wait()?; let status = child.wait()?;
Ok(Output { status, stdout: stdout.into_bytes(), stderr: stderr.into_bytes() }) let truncated =
if stdout.truncated() || stderr.truncated() { Truncated::Yes } else { Truncated::No };
Ok((Output { status, stdout: stdout.into_bytes(), stderr: stderr.into_bytes() }, truncated))
} }
const MAX_OUT_LEN: usize = 512 * 1024; const MAX_OUT_LEN: usize = 512 * 1024;
@ -46,6 +57,10 @@ fn new() -> Self {
ProcOutput::Full { bytes: Vec::new(), filtered_len: 0 } ProcOutput::Full { bytes: Vec::new(), filtered_len: 0 }
} }
fn truncated(&self) -> bool {
matches!(self, Self::Abbreviated { .. })
}
fn extend(&mut self, data: &[u8], filter_paths_from_len: &[String]) { fn extend(&mut self, data: &[u8], filter_paths_from_len: &[String]) {
let new_self = match *self { let new_self = match *self {
ProcOutput::Full { ref mut bytes, ref mut filtered_len } => { ProcOutput::Full { ref mut bytes, ref mut filtered_len } => {

View File

@ -12,7 +12,7 @@
use crate::errors::{self, Error, ErrorKind}; use crate::errors::{self, Error, ErrorKind};
use crate::header::TestProps; use crate::header::TestProps;
use crate::json; use crate::json;
use crate::read2::read2_abbreviated; use crate::read2::{read2_abbreviated, Truncated};
use crate::util::{add_dylib_path, dylib_env_var, logv, PathBufExt}; use crate::util::{add_dylib_path, dylib_env_var, logv, PathBufExt};
use crate::ColorConfig; use crate::ColorConfig;
use regex::{Captures, Regex}; use regex::{Captures, Regex};
@ -701,6 +701,7 @@ fn run_command_to_procres(&self, cmd: &mut Command) -> ProcRes {
status: output.status, status: output.status,
stdout: String::from_utf8(output.stdout).unwrap(), stdout: String::from_utf8(output.stdout).unwrap(),
stderr: String::from_utf8(output.stderr).unwrap(), stderr: String::from_utf8(output.stderr).unwrap(),
truncated: Truncated::No,
cmdline: format!("{cmd:?}"), cmdline: format!("{cmd:?}"),
}; };
self.dump_output(&proc_res.stdout, &proc_res.stderr); self.dump_output(&proc_res.stdout, &proc_res.stderr);
@ -1275,6 +1276,7 @@ fn run_debuginfo_gdb_test_no_opt(&self) {
status, status,
stdout: String::from_utf8(stdout).unwrap(), stdout: String::from_utf8(stdout).unwrap(),
stderr: String::from_utf8(stderr).unwrap(), stderr: String::from_utf8(stderr).unwrap(),
truncated: Truncated::No,
cmdline, cmdline,
}; };
if adb.kill().is_err() { if adb.kill().is_err() {
@ -1557,7 +1559,13 @@ fn cmd2procres(&self, cmd: &mut Command) -> ProcRes {
}; };
self.dump_output(&out, &err); self.dump_output(&out, &err);
ProcRes { status, stdout: out, stderr: err, cmdline: format!("{:?}", cmd) } ProcRes {
status,
stdout: out,
stderr: err,
truncated: Truncated::No,
cmdline: format!("{:?}", cmd),
}
} }
fn cleanup_debug_info_options(&self, options: &Vec<String>) -> Vec<String> { fn cleanup_debug_info_options(&self, options: &Vec<String>) -> Vec<String> {
@ -2218,7 +2226,7 @@ fn build_auxiliary(&self, source_path: &str, aux_dir: &Path) -> bool {
dylib dylib
} }
fn read2_abbreviated(&self, child: Child) -> Output { fn read2_abbreviated(&self, child: Child) -> (Output, Truncated) {
let mut filter_paths_from_len = Vec::new(); let mut filter_paths_from_len = Vec::new();
let mut add_path = |path: &Path| { let mut add_path = |path: &Path| {
let path = path.display().to_string(); let path = path.display().to_string();
@ -2265,12 +2273,13 @@ fn compose_and_run(
child.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap(); child.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
} }
let Output { status, stdout, stderr } = self.read2_abbreviated(child); let (Output { status, stdout, stderr }, truncated) = self.read2_abbreviated(child);
let result = ProcRes { let result = ProcRes {
status, status,
stdout: String::from_utf8_lossy(&stdout).into_owned(), stdout: String::from_utf8_lossy(&stdout).into_owned(),
stderr: String::from_utf8_lossy(&stderr).into_owned(), stderr: String::from_utf8_lossy(&stderr).into_owned(),
truncated,
cmdline, cmdline,
}; };
@ -3601,12 +3610,14 @@ fn run_rmake_test(&self) {
} }
} }
let output = self.read2_abbreviated(cmd.spawn().expect("failed to spawn `make`")); let (output, truncated) =
self.read2_abbreviated(cmd.spawn().expect("failed to spawn `make`"));
if !output.status.success() { if !output.status.success() {
let res = ProcRes { let res = ProcRes {
status: output.status, status: output.status,
stdout: String::from_utf8_lossy(&output.stdout).into_owned(), stdout: String::from_utf8_lossy(&output.stdout).into_owned(),
stderr: String::from_utf8_lossy(&output.stderr).into_owned(), stderr: String::from_utf8_lossy(&output.stderr).into_owned(),
truncated,
cmdline: format!("{:?}", cmd), cmdline: format!("{:?}", cmd),
}; };
self.fatal_proc_rec("make failed", &res); self.fatal_proc_rec("make failed", &res);
@ -3768,6 +3779,15 @@ fn run_ui_test(&self) {
let emit_metadata = self.should_emit_metadata(pm); let emit_metadata = self.should_emit_metadata(pm);
let proc_res = self.compile_test(should_run, emit_metadata); let proc_res = self.compile_test(should_run, emit_metadata);
self.check_if_test_should_compile(&proc_res, pm); self.check_if_test_should_compile(&proc_res, pm);
if matches!(proc_res.truncated, Truncated::Yes)
&& !self.props.dont_check_compiler_stdout
&& !self.props.dont_check_compiler_stderr
{
self.fatal_proc_rec(
&format!("compiler output got truncated, cannot compare with reference file"),
&proc_res,
);
}
// if the user specified a format in the ui test // if the user specified a format in the ui test
// print the output to the stderr file, otherwise extract // print the output to the stderr file, otherwise extract
@ -4459,6 +4479,7 @@ pub struct ProcRes {
status: ExitStatus, status: ExitStatus,
stdout: String, stdout: String,
stderr: String, stderr: String,
truncated: Truncated,
cmdline: String, cmdline: String,
} }