Skip to content

Commit 9cf2798

Browse files
committed
don't even try to compare with reference when there was truncation
1 parent ef46066 commit 9cf2798

File tree

2 files changed

+43
-7
lines changed

2 files changed

+43
-7
lines changed

src/tools/compiletest/src/read2.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ use std::io::{self, Write};
99
use std::mem::replace;
1010
use std::process::{Child, Output};
1111

12-
pub fn read2_abbreviated(mut child: Child, filter_paths_from_len: &[String]) -> io::Result<Output> {
12+
#[derive(Copy, Clone, Debug)]
13+
pub enum Truncated {
14+
Yes,
15+
No,
16+
}
17+
18+
pub fn read2_abbreviated(
19+
mut child: Child,
20+
filter_paths_from_len: &[String],
21+
) -> io::Result<(Output, Truncated)> {
1322
let mut stdout = ProcOutput::new();
1423
let mut stderr = ProcOutput::new();
1524

@@ -24,7 +33,9 @@ pub fn read2_abbreviated(mut child: Child, filter_paths_from_len: &[String]) ->
2433
)?;
2534
let status = child.wait()?;
2635

27-
Ok(Output { status, stdout: stdout.into_bytes(), stderr: stderr.into_bytes() })
36+
let truncated =
37+
if stdout.truncated() || stderr.truncated() { Truncated::Yes } else { Truncated::No };
38+
Ok((Output { status, stdout: stdout.into_bytes(), stderr: stderr.into_bytes() }, truncated))
2839
}
2940

3041
const MAX_OUT_LEN: usize = 512 * 1024;
@@ -46,6 +57,10 @@ impl ProcOutput {
4657
ProcOutput::Full { bytes: Vec::new(), filtered_len: 0 }
4758
}
4859

60+
fn truncated(&self) -> bool {
61+
matches!(self, Self::Abbreviated { .. })
62+
}
63+
4964
fn extend(&mut self, data: &[u8], filter_paths_from_len: &[String]) {
5065
let new_self = match *self {
5166
ProcOutput::Full { ref mut bytes, ref mut filtered_len } => {

src/tools/compiletest/src/runtest.rs

+26-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::compute_diff::{write_diff, write_filtered_diff};
1212
use crate::errors::{self, Error, ErrorKind};
1313
use crate::header::TestProps;
1414
use crate::json;
15-
use crate::read2::read2_abbreviated;
15+
use crate::read2::{read2_abbreviated, Truncated};
1616
use crate::util::{add_dylib_path, dylib_env_var, logv, PathBufExt};
1717
use crate::ColorConfig;
1818
use regex::{Captures, Regex};
@@ -701,6 +701,7 @@ impl<'test> TestCx<'test> {
701701
status: output.status,
702702
stdout: String::from_utf8(output.stdout).unwrap(),
703703
stderr: String::from_utf8(output.stderr).unwrap(),
704+
truncated: Truncated::No,
704705
cmdline: format!("{cmd:?}"),
705706
};
706707
self.dump_output(&proc_res.stdout, &proc_res.stderr);
@@ -1275,6 +1276,7 @@ impl<'test> TestCx<'test> {
12751276
status,
12761277
stdout: String::from_utf8(stdout).unwrap(),
12771278
stderr: String::from_utf8(stderr).unwrap(),
1279+
truncated: Truncated::No,
12781280
cmdline,
12791281
};
12801282
if adb.kill().is_err() {
@@ -1557,7 +1559,13 @@ impl<'test> TestCx<'test> {
15571559
};
15581560

15591561
self.dump_output(&out, &err);
1560-
ProcRes { status, stdout: out, stderr: err, cmdline: format!("{:?}", cmd) }
1562+
ProcRes {
1563+
status,
1564+
stdout: out,
1565+
stderr: err,
1566+
truncated: Truncated::No,
1567+
cmdline: format!("{:?}", cmd),
1568+
}
15611569
}
15621570

15631571
fn cleanup_debug_info_options(&self, options: &Vec<String>) -> Vec<String> {
@@ -2218,7 +2226,7 @@ impl<'test> TestCx<'test> {
22182226
dylib
22192227
}
22202228

2221-
fn read2_abbreviated(&self, child: Child) -> Output {
2229+
fn read2_abbreviated(&self, child: Child) -> (Output, Truncated) {
22222230
let mut filter_paths_from_len = Vec::new();
22232231
let mut add_path = |path: &Path| {
22242232
let path = path.display().to_string();
@@ -2265,12 +2273,13 @@ impl<'test> TestCx<'test> {
22652273
child.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
22662274
}
22672275

2268-
let Output { status, stdout, stderr } = self.read2_abbreviated(child);
2276+
let (Output { status, stdout, stderr }, truncated) = self.read2_abbreviated(child);
22692277

22702278
let result = ProcRes {
22712279
status,
22722280
stdout: String::from_utf8_lossy(&stdout).into_owned(),
22732281
stderr: String::from_utf8_lossy(&stderr).into_owned(),
2282+
truncated,
22742283
cmdline,
22752284
};
22762285

@@ -3601,12 +3610,14 @@ impl<'test> TestCx<'test> {
36013610
}
36023611
}
36033612

3604-
let output = self.read2_abbreviated(cmd.spawn().expect("failed to spawn `make`"));
3613+
let (output, truncated) =
3614+
self.read2_abbreviated(cmd.spawn().expect("failed to spawn `make`"));
36053615
if !output.status.success() {
36063616
let res = ProcRes {
36073617
status: output.status,
36083618
stdout: String::from_utf8_lossy(&output.stdout).into_owned(),
36093619
stderr: String::from_utf8_lossy(&output.stderr).into_owned(),
3620+
truncated,
36103621
cmdline: format!("{:?}", cmd),
36113622
};
36123623
self.fatal_proc_rec("make failed", &res);
@@ -3768,6 +3779,15 @@ impl<'test> TestCx<'test> {
37683779
let emit_metadata = self.should_emit_metadata(pm);
37693780
let proc_res = self.compile_test(should_run, emit_metadata);
37703781
self.check_if_test_should_compile(&proc_res, pm);
3782+
if matches!(proc_res.truncated, Truncated::Yes)
3783+
&& !self.props.dont_check_compiler_stdout
3784+
&& !self.props.dont_check_compiler_stderr
3785+
{
3786+
self.fatal_proc_rec(
3787+
&format!("compiler output got truncated, cannot compare with reference file"),
3788+
&proc_res,
3789+
);
3790+
}
37713791

37723792
// if the user specified a format in the ui test
37733793
// print the output to the stderr file, otherwise extract
@@ -4459,6 +4479,7 @@ pub struct ProcRes {
44594479
status: ExitStatus,
44604480
stdout: String,
44614481
stderr: String,
4482+
truncated: Truncated,
44624483
cmdline: String,
44634484
}
44644485

0 commit comments

Comments
 (0)