Skip to content

Commit 3f933f7

Browse files
author
Orion Gonzalez
committed
try to add flag
1 parent ed8e1fa commit 3f933f7

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

config.example.toml

+3
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,9 @@
414414
# Specify the location of the Android NDK. Used when targeting Android.
415415
#android-ndk = "/path/to/android-ndk-r26d"
416416

417+
# What custom diff tool to use for displaying compiletest tests.
418+
#display-diff-tool = "difft --color=always --background=light --display=side-by-side"
419+
417420
# =============================================================================
418421
# General install configuration options
419422
# =============================================================================

src/bootstrap/src/core/build_steps/test.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,9 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
18391839

18401840
let mut flags = if is_rustdoc { Vec::new() } else { vec!["-Crpath".to_string()] };
18411841
flags.push(format!("-Cdebuginfo={}", builder.config.rust_debuginfo_level_tests));
1842+
if let Some(display_diff_tool) = &builder.config.display_diff_tool {
1843+
flags.push(format!(r#"--display-diff-tool="{display_diff_tool}""#));
1844+
}
18421845
flags.extend(builder.config.cmd.compiletest_rustc_args().iter().map(|s| s.to_string()));
18431846

18441847
if suite != "mir-opt" {

src/bootstrap/src/core/config/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ pub struct Config {
365365
/// The paths to work with. For example: with `./x check foo bar` we get
366366
/// `paths=["foo", "bar"]`.
367367
pub paths: Vec<PathBuf>,
368+
369+
/// What custom diff tool to use for displaying compiletest tests.
370+
pub display_diff_tool: Option<String>,
368371
}
369372

370373
#[derive(Clone, Debug, Default)]
@@ -885,6 +888,7 @@ define_config! {
885888
metrics: Option<bool> = "metrics",
886889
android_ndk: Option<PathBuf> = "android-ndk",
887890
optimized_compiler_builtins: Option<bool> = "optimized-compiler-builtins",
891+
display_diff_tool: Option<String> = "display-diff-tool",
888892
}
889893
}
890894

@@ -1504,6 +1508,7 @@ impl Config {
15041508
metrics: _,
15051509
android_ndk,
15061510
optimized_compiler_builtins,
1511+
display_diff_tool,
15071512
} = toml.build.unwrap_or_default();
15081513

15091514
if let Some(file_build) = build {
@@ -2141,6 +2146,7 @@ impl Config {
21412146
config.rust_debuginfo_level_tests = debuginfo_level_tests.unwrap_or(DebuginfoLevel::None);
21422147
config.optimized_compiler_builtins =
21432148
optimized_compiler_builtins.unwrap_or(config.channel != "dev");
2149+
config.display_diff_tool = display_diff_tool;
21442150

21452151
let download_rustc = config.download_rustc_commit.is_some();
21462152
// See https://github.com/rust-lang/compiler-team/issues/326

src/tools/compiletest/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ pub fn parse_config(args: Vec<String>) -> Config {
171171
"git-merge-commit-email",
172172
"email address used for finding merge commits",
173173
"EMAIL",
174-
);
174+
)
175+
.optopt("", "display-diff-tool", "What custom diff tool to use for displaying compiletest tests.", "COMMAND")
176+
;
175177

176178
let (argv0, args_) = args.split_first().unwrap();
177179
if args.len() == 1 || args[1] == "-h" || args[1] == "--help" {
@@ -360,7 +362,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
360362
git_merge_commit_email: matches.opt_str("git-merge-commit-email").unwrap(),
361363

362364
profiler_support: matches.opt_present("profiler-support"),
363-
diff_command: env::var("COMPILETEST_DIFF_TOOL").ok(),
365+
diff_command: matches.opt_str("display-diff-tool"),
364366
}
365367
}
366368

src/tools/compiletest/src/runtest.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2555,7 +2555,8 @@ impl<'test> TestCx<'test> {
25552555
));
25562556
}
25572557
Ok(output) => {
2558-
io::stdout().lock().write_all(&output.stdout).unwrap();
2558+
let output = String::from_utf8_lossy_owned(output.stdout).unwrap();
2559+
print!("{output}");
25592560
}
25602561
}
25612562
} else {

0 commit comments

Comments
 (0)