Skip to content

Commit

Permalink
compiletest: print{,ln}! -> eprint{,ln}!
Browse files Browse the repository at this point in the history
Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
  • Loading branch information
clubby789 and jieyouxu committed Dec 9, 2024
1 parent 15d7331 commit a6c4628
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 57 deletions.
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/compute_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ where
}

if !wrote_data {
println!("note: diff is identical to nightly rustdoc");
eprintln!("note: diff is identical to nightly rustdoc");
assert!(diff_output.metadata().unwrap().len() == 0);
return false;
} else if verbose {
Expand Down
6 changes: 3 additions & 3 deletions src/tools/compiletest/src/debuggers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ pub(crate) fn configure_gdb(config: &Config) -> Option<Arc<Config>> {
}

if config.remote_test_client.is_some() && !config.target.contains("android") {
println!(
eprintln!(
"WARNING: debuginfo tests are not available when \
testing with remote"
);
return None;
}

if config.target.contains("android") {
println!(
eprintln!(
"{} debug-info test uses tcp 5039 port.\
please reserve it",
config.target
Expand All @@ -50,7 +50,7 @@ pub(crate) fn configure_lldb(config: &Config) -> Option<Arc<Config>> {
config.lldb_python_dir.as_ref()?;

if let Some(350) = config.lldb_version {
println!(
eprintln!(
"WARNING: The used version of LLDB (350) has a \
known issue that breaks debuginfo tests. See \
issue #32520 for more information. Skipping all \
Expand Down
10 changes: 5 additions & 5 deletions src/tools/compiletest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
let (argv0, args_) = args.split_first().unwrap();
if args.len() == 1 || args[1] == "-h" || args[1] == "--help" {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
println!("{}", opts.usage(&message));
println!();
eprintln!("{}", opts.usage(&message));
eprintln!();
panic!()
}

Expand All @@ -200,8 +200,8 @@ pub fn parse_config(args: Vec<String>) -> Config {

if matches.opt_present("h") || matches.opt_present("help") {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
println!("{}", opts.usage(&message));
println!();
eprintln!("{}", opts.usage(&message));
eprintln!();
panic!()
}

Expand Down Expand Up @@ -508,7 +508,7 @@ pub fn run_tests(config: Arc<Config>) {
// easy to miss which tests failed, and as such fail to reproduce
// the failure locally.

println!(
eprintln!(
"Some tests failed in compiletest suite={}{} mode={} host={} target={}",
config.suite,
config
Expand Down
52 changes: 26 additions & 26 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub fn run(config: Arc<Config>, testpaths: &TestPaths, revision: Option<&str>) {

if config.verbose {
// We're going to be dumping a lot of info. Start on a new line.
print!("\n\n");
eprintln!("\n");
}
debug!("running {:?}", testpaths.file.display());
let mut props = TestProps::from_file(&testpaths.file, revision, &config);
Expand Down Expand Up @@ -353,7 +353,7 @@ impl<'test> TestCx<'test> {
{
self.error(&format!("{} test did not emit an error", self.config.mode));
if self.config.mode == crate::common::Mode::Ui {
println!("note: by default, ui tests are expected not to compile");
eprintln!("note: by default, ui tests are expected not to compile");
}
proc_res.fatal(None, || ());
};
Expand Down Expand Up @@ -774,20 +774,20 @@ impl<'test> TestCx<'test> {
unexpected.len(),
not_found.len()
));
println!("status: {}\ncommand: {}\n", proc_res.status, proc_res.cmdline);
eprintln!("status: {}\ncommand: {}\n", proc_res.status, proc_res.cmdline);
if !unexpected.is_empty() {
println!("{}", "--- unexpected errors (from JSON output) ---".green());
eprintln!("{}", "--- unexpected errors (from JSON output) ---".green());
for error in &unexpected {
println!("{}", error.render_for_expected());
eprintln!("{}", error.render_for_expected());
}
println!("{}", "---".green());
eprintln!("{}", "---".green());
}
if !not_found.is_empty() {
println!("{}", "--- not found errors (from test file) ---".red());
eprintln!("{}", "--- not found errors (from test file) ---".red());
for error in &not_found {
println!("{}", error.render_for_expected());
eprintln!("{}", error.render_for_expected());
}
println!("{}", "---\n".red());
eprintln!("{}", "---\n".red());
}
panic!("errors differ from expected");
}
Expand Down Expand Up @@ -1876,18 +1876,18 @@ impl<'test> TestCx<'test> {

fn maybe_dump_to_stdout(&self, out: &str, err: &str) {
if self.config.verbose {
println!("------stdout------------------------------");
println!("{}", out);
println!("------stderr------------------------------");
println!("{}", err);
println!("------------------------------------------");
eprintln!("------stdout------------------------------");
eprintln!("{}", out);
eprintln!("------stderr------------------------------");
eprintln!("{}", err);
eprintln!("------------------------------------------");
}
}

fn error(&self, err: &str) {
match self.revision {
Some(rev) => println!("\nerror in revision `{}`: {}", rev, err),
None => println!("\nerror: {}", err),
Some(rev) => eprintln!("\nerror in revision `{}`: {}", rev, err),
None => eprintln!("\nerror: {}", err),
}
}

Expand Down Expand Up @@ -1972,7 +1972,7 @@ impl<'test> TestCx<'test> {
if !self.config.has_html_tidy {
return;
}
println!("info: generating a diff against nightly rustdoc");
eprintln!("info: generating a diff against nightly rustdoc");

let suffix =
self.safe_revision().map_or("nightly".into(), |path| path.to_owned() + "-nightly");
Expand Down Expand Up @@ -2082,7 +2082,7 @@ impl<'test> TestCx<'test> {
.output()
.unwrap();
assert!(output.status.success());
println!("{}", String::from_utf8_lossy(&output.stdout));
eprintln!("{}", String::from_utf8_lossy(&output.stdout));
eprintln!("{}", String::from_utf8_lossy(&output.stderr));
} else {
use colored::Colorize;
Expand Down Expand Up @@ -2496,7 +2496,7 @@ impl<'test> TestCx<'test> {
)"#
)
.replace_all(&output, |caps: &Captures<'_>| {
println!("{}", &caps[0]);
eprintln!("{}", &caps[0]);
caps[0].replace(r"\", "/")
})
.replace("\r\n", "\n")
Expand Down Expand Up @@ -2601,14 +2601,14 @@ impl<'test> TestCx<'test> {
if let Err(err) = fs::write(&actual_path, &actual) {
self.fatal(&format!("failed to write {stream} to `{actual_path:?}`: {err}",));
}
println!("Saved the actual {stream} to {actual_path:?}");
eprintln!("Saved the actual {stream} to {actual_path:?}");

let expected_path =
expected_output_path(self.testpaths, self.revision, &self.config.compare_mode, stream);

if !self.config.bless {
if expected.is_empty() {
println!("normalized {}:\n{}\n", stream, actual);
eprintln!("normalized {}:\n{}\n", stream, actual);
} else {
self.show_diff(
stream,
Expand All @@ -2631,10 +2631,10 @@ impl<'test> TestCx<'test> {
if let Err(err) = fs::write(&expected_path, &actual) {
self.fatal(&format!("failed to write {stream} to `{expected_path:?}`: {err}"));
}
println!("Blessing the {stream} of {test_name} in {expected_path:?}");
eprintln!("Blessing the {stream} of {test_name} in {expected_path:?}");
}

println!("\nThe actual {0} differed from the expected {0}.", stream);
eprintln!("\nThe actual {0} differed from the expected {0}.", stream);

if self.config.bless { 0 } else { 1 }
}
Expand Down Expand Up @@ -2783,7 +2783,7 @@ impl<'test> TestCx<'test> {
fs::create_dir_all(&incremental_dir).unwrap();

if self.config.verbose {
println!("init_incremental_test: incremental_dir={}", incremental_dir.display());
eprintln!("init_incremental_test: incremental_dir={}", incremental_dir.display());
}
}

Expand Down Expand Up @@ -2841,7 +2841,7 @@ impl ProcRes {
}
}

println!(
eprintln!(
"status: {}\ncommand: {}\n{}\n{}\n",
self.status,
self.cmdline,
Expand All @@ -2852,7 +2852,7 @@ impl ProcRes {

pub fn fatal(&self, err: Option<&str>, on_failure: impl FnOnce()) -> ! {
if let Some(e) = err {
println!("\nerror: {}", e);
eprintln!("\nerror: {}", e);
}
self.print_info();
on_failure();
Expand Down
22 changes: 11 additions & 11 deletions src/tools/compiletest/src/runtest/codegen_units.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ impl TestCx<'_> {
if !missing.is_empty() {
missing.sort();

println!("\nThese items should have been contained but were not:\n");
eprintln!("\nThese items should have been contained but were not:\n");

for item in &missing {
println!("{}", item);
eprintln!("{}", item);
}

println!("\n");
eprintln!("\n");
}

if !unexpected.is_empty() {
Expand All @@ -80,24 +80,24 @@ impl TestCx<'_> {
sorted
};

println!("\nThese items were contained but should not have been:\n");
eprintln!("\nThese items were contained but should not have been:\n");

for item in sorted {
println!("{}", item);
eprintln!("{}", item);
}

println!("\n");
eprintln!("\n");
}

if !wrong_cgus.is_empty() {
wrong_cgus.sort_by_key(|pair| pair.0.name.clone());
println!("\nThe following items were assigned to wrong codegen units:\n");
eprintln!("\nThe following items were assigned to wrong codegen units:\n");

for &(ref expected_item, ref actual_item) in &wrong_cgus {
println!("{}", expected_item.name);
println!(" expected: {}", codegen_units_to_str(&expected_item.codegen_units));
println!(" actual: {}", codegen_units_to_str(&actual_item.codegen_units));
println!();
eprintln!("{}", expected_item.name);
eprintln!(" expected: {}", codegen_units_to_str(&expected_item.codegen_units));
eprintln!(" actual: {}", codegen_units_to_str(&actual_item.codegen_units));
eprintln!();
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/tools/compiletest/src/runtest/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ impl TestCx<'_> {
cmdline,
};
if adb.kill().is_err() {
println!("Adb process is already finished.");
eprintln!("Adb process is already finished.");
}
} else {
let rust_src_root =
Expand All @@ -275,7 +275,7 @@ impl TestCx<'_> {

match self.config.gdb_version {
Some(version) => {
println!("NOTE: compiletest thinks it is using GDB version {}", version);
eprintln!("NOTE: compiletest thinks it is using GDB version {}", version);

if version > extract_gdb_version("7.4").unwrap() {
// Add the directory containing the pretty printers to
Expand All @@ -297,7 +297,7 @@ impl TestCx<'_> {
}
}
_ => {
println!(
eprintln!(
"NOTE: compiletest does not know which version of \
GDB it is using"
);
Expand Down Expand Up @@ -392,10 +392,10 @@ impl TestCx<'_> {

match self.config.lldb_version {
Some(ref version) => {
println!("NOTE: compiletest thinks it is using LLDB version {}", version);
eprintln!("NOTE: compiletest thinks it is using LLDB version {}", version);
}
_ => {
println!(
eprintln!(
"NOTE: compiletest does not know which version of \
LLDB it is using"
);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/runtest/incremental.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl TestCx<'_> {
assert!(incremental_dir.exists(), "init_incremental_test failed to create incremental dir");

if self.config.verbose {
print!("revision={:?} props={:#?}", revision, self.props);
eprint!("revision={:?} props={:#?}", revision, self.props);
}

if revision.starts_with("cpass") {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/runtest/mir_opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl TestCx<'_> {
}
let expected_string = fs::read_to_string(&expected_file).unwrap();
if dumped_string != expected_string {
print!("{}", write_diff(&expected_string, &dumped_string, 3));
eprint!("{}", write_diff(&expected_string, &dumped_string, 3));
panic!(
"Actual MIR output differs from expected MIR output {}",
expected_file.display()
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/runtest/rustdoc_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl TestCx<'_> {

if !res.status.success() {
self.fatal_proc_rec_with_ctx("jsondocck failed!", &res, |_| {
println!("Rustdoc Output:");
eprintln!("Rustdoc Output:");
proc_res.print_info();
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/runtest/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ impl TestCx<'_> {
}

if errors > 0 {
println!("To update references, rerun the tests and pass the `--bless` flag");
eprintln!("To update references, rerun the tests and pass the `--bless` flag");
let relative_path_to_file =
self.testpaths.relative_dir.join(self.testpaths.file.file_name().unwrap());
println!(
eprintln!(
"To only update this specific test, also pass `--test-args {}`",
relative_path_to_file.display(),
);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn path_div() -> &'static str {
pub fn logv(config: &Config, s: String) {
debug!("{}", s);
if config.verbose {
println!("{}", s);
eprintln!("{}", s);
}
}

Expand Down

0 comments on commit a6c4628

Please sign in to comment.