Skip to content

Commit

Permalink
try to add flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Orion Gonzalez committed Oct 3, 2024
1 parent ed8e1fa commit 3f933f7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@
# Specify the location of the Android NDK. Used when targeting Android.
#android-ndk = "/path/to/android-ndk-r26d"

# What custom diff tool to use for displaying compiletest tests.
#display-diff-tool = "difft --color=always --background=light --display=side-by-side"

# =============================================================================
# General install configuration options
# =============================================================================
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,9 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the

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

if suite != "mir-opt" {
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,9 @@ pub struct Config {
/// The paths to work with. For example: with `./x check foo bar` we get
/// `paths=["foo", "bar"]`.
pub paths: Vec<PathBuf>,

/// What custom diff tool to use for displaying compiletest tests.
pub display_diff_tool: Option<String>,
}

#[derive(Clone, Debug, Default)]
Expand Down Expand Up @@ -885,6 +888,7 @@ define_config! {
metrics: Option<bool> = "metrics",
android_ndk: Option<PathBuf> = "android-ndk",
optimized_compiler_builtins: Option<bool> = "optimized-compiler-builtins",
display_diff_tool: Option<String> = "display-diff-tool",
}
}

Expand Down Expand Up @@ -1504,6 +1508,7 @@ impl Config {
metrics: _,
android_ndk,
optimized_compiler_builtins,
display_diff_tool,
} = toml.build.unwrap_or_default();

if let Some(file_build) = build {
Expand Down Expand Up @@ -2141,6 +2146,7 @@ impl Config {
config.rust_debuginfo_level_tests = debuginfo_level_tests.unwrap_or(DebuginfoLevel::None);
config.optimized_compiler_builtins =
optimized_compiler_builtins.unwrap_or(config.channel != "dev");
config.display_diff_tool = display_diff_tool;

let download_rustc = config.download_rustc_commit.is_some();
// See https://github.com/rust-lang/compiler-team/issues/326
Expand Down
6 changes: 4 additions & 2 deletions src/tools/compiletest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ pub fn parse_config(args: Vec<String>) -> Config {
"git-merge-commit-email",
"email address used for finding merge commits",
"EMAIL",
);
)
.optopt("", "display-diff-tool", "What custom diff tool to use for displaying compiletest tests.", "COMMAND")
;

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

profiler_support: matches.opt_present("profiler-support"),
diff_command: env::var("COMPILETEST_DIFF_TOOL").ok(),
diff_command: matches.opt_str("display-diff-tool"),
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2555,7 +2555,8 @@ impl<'test> TestCx<'test> {
));
}
Ok(output) => {
io::stdout().lock().write_all(&output.stdout).unwrap();
let output = String::from_utf8_lossy_owned(output.stdout).unwrap();
print!("{output}");
}
}
} else {
Expand Down

0 comments on commit 3f933f7

Please sign in to comment.