Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ dependencies = [
"semver",
"serde",
"serde_json",
"shlex",
"tracing",
"tracing-subscriber",
"unified-diff",
Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ rustfix = "0.8.1"
semver = { version = "1.0.23", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
shlex = "1.3.0"
tracing = "0.1"
tracing-subscriber = { version = "0.3.3", default-features = false, features = ["ansi", "env-filter", "fmt", "parking_lot", "smallvec"] }
unified-diff = "0.2.1"
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,6 @@ fn split_flags(flags: &str) -> Vec<String> {
.split('\'')
.enumerate()
.flat_map(|(i, f)| if i % 2 == 1 { vec![f] } else { f.split_whitespace().collect() })
.map(move |s| s.to_owned())
.collect::<Vec<_>>()
.map(|s| s.to_owned())
.collect()
}
30 changes: 20 additions & 10 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2835,17 +2835,27 @@ impl<'test> TestCx<'test> {
) {
writeln!(self.stderr, "diff of {stream}:\n");
if let Some(diff_command) = self.config.diff_command.as_deref() {
let mut args = diff_command.split_whitespace();
let name = args.next().unwrap();
match Command::new(name).args(args).args([expected_path, actual_path]).output() {
Err(err) => {
self.fatal(&format!(
"failed to call custom diff command `{diff_command}`: {err}"
));
match shlex::split(diff_command) {
Comment on lines 2837 to +2838

@jieyouxu jieyouxu Apr 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View changes since the review

Remark: so actually, this case I care less about, properly splitting diff command stuff is "nice-to-have" for users on custom diff tools but this is not correctness-critical

Some(mut args) if !args.is_empty() => {
let name = args.remove(0);
match Command::new(name).args(args).args([expected_path, actual_path]).output()
{
Err(err) => {
self.fatal(&format!(
"failed to call custom diff command `{diff_command}`: {err}"
));
}
Ok(output) => {
let output = String::from_utf8_lossy(&output.stdout);
write!(self.stderr, "{output}");
}
}
}
Ok(output) => {
let output = String::from_utf8_lossy(&output.stdout);
write!(self.stderr, "{output}");
Some(_) => {
self.fatal(&format!("custom diff command is empty: `{diff_command}`"));
}
None => {
self.fatal(&format!("failed to parse custom diff command: `{diff_command}`"));
}
}
} else {
Expand Down
Loading