Skip to content

Commit a6c4628

Browse files
clubby789jieyouxu
andcommitted
compiletest: print{,ln}! -> eprint{,ln}!
Co-authored-by: Jieyou Xu <[email protected]>
1 parent 15d7331 commit a6c4628

File tree

11 files changed

+57
-57
lines changed

11 files changed

+57
-57
lines changed

src/tools/compiletest/src/compute_diff.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ where
144144
}
145145

146146
if !wrote_data {
147-
println!("note: diff is identical to nightly rustdoc");
147+
eprintln!("note: diff is identical to nightly rustdoc");
148148
assert!(diff_output.metadata().unwrap().len() == 0);
149149
return false;
150150
} else if verbose {

src/tools/compiletest/src/debuggers.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ pub(crate) fn configure_gdb(config: &Config) -> Option<Arc<Config>> {
2020
}
2121

2222
if config.remote_test_client.is_some() && !config.target.contains("android") {
23-
println!(
23+
eprintln!(
2424
"WARNING: debuginfo tests are not available when \
2525
testing with remote"
2626
);
2727
return None;
2828
}
2929

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

5252
if let Some(350) = config.lldb_version {
53-
println!(
53+
eprintln!(
5454
"WARNING: The used version of LLDB (350) has a \
5555
known issue that breaks debuginfo tests. See \
5656
issue #32520 for more information. Skipping all \

src/tools/compiletest/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
188188
let (argv0, args_) = args.split_first().unwrap();
189189
if args.len() == 1 || args[1] == "-h" || args[1] == "--help" {
190190
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
191-
println!("{}", opts.usage(&message));
192-
println!();
191+
eprintln!("{}", opts.usage(&message));
192+
eprintln!();
193193
panic!()
194194
}
195195

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

201201
if matches.opt_present("h") || matches.opt_present("help") {
202202
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
203-
println!("{}", opts.usage(&message));
204-
println!();
203+
eprintln!("{}", opts.usage(&message));
204+
eprintln!();
205205
panic!()
206206
}
207207

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

511-
println!(
511+
eprintln!(
512512
"Some tests failed in compiletest suite={}{} mode={} host={} target={}",
513513
config.suite,
514514
config

src/tools/compiletest/src/runtest.rs

+26-26
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub fn run(config: Arc<Config>, testpaths: &TestPaths, revision: Option<&str>) {
131131

132132
if config.verbose {
133133
// We're going to be dumping a lot of info. Start on a new line.
134-
print!("\n\n");
134+
eprintln!("\n");
135135
}
136136
debug!("running {:?}", testpaths.file.display());
137137
let mut props = TestProps::from_file(&testpaths.file, revision, &config);
@@ -353,7 +353,7 @@ impl<'test> TestCx<'test> {
353353
{
354354
self.error(&format!("{} test did not emit an error", self.config.mode));
355355
if self.config.mode == crate::common::Mode::Ui {
356-
println!("note: by default, ui tests are expected not to compile");
356+
eprintln!("note: by default, ui tests are expected not to compile");
357357
}
358358
proc_res.fatal(None, || ());
359359
};
@@ -774,20 +774,20 @@ impl<'test> TestCx<'test> {
774774
unexpected.len(),
775775
not_found.len()
776776
));
777-
println!("status: {}\ncommand: {}\n", proc_res.status, proc_res.cmdline);
777+
eprintln!("status: {}\ncommand: {}\n", proc_res.status, proc_res.cmdline);
778778
if !unexpected.is_empty() {
779-
println!("{}", "--- unexpected errors (from JSON output) ---".green());
779+
eprintln!("{}", "--- unexpected errors (from JSON output) ---".green());
780780
for error in &unexpected {
781-
println!("{}", error.render_for_expected());
781+
eprintln!("{}", error.render_for_expected());
782782
}
783-
println!("{}", "---".green());
783+
eprintln!("{}", "---".green());
784784
}
785785
if !not_found.is_empty() {
786-
println!("{}", "--- not found errors (from test file) ---".red());
786+
eprintln!("{}", "--- not found errors (from test file) ---".red());
787787
for error in &not_found {
788-
println!("{}", error.render_for_expected());
788+
eprintln!("{}", error.render_for_expected());
789789
}
790-
println!("{}", "---\n".red());
790+
eprintln!("{}", "---\n".red());
791791
}
792792
panic!("errors differ from expected");
793793
}
@@ -1876,18 +1876,18 @@ impl<'test> TestCx<'test> {
18761876

18771877
fn maybe_dump_to_stdout(&self, out: &str, err: &str) {
18781878
if self.config.verbose {
1879-
println!("------stdout------------------------------");
1880-
println!("{}", out);
1881-
println!("------stderr------------------------------");
1882-
println!("{}", err);
1883-
println!("------------------------------------------");
1879+
eprintln!("------stdout------------------------------");
1880+
eprintln!("{}", out);
1881+
eprintln!("------stderr------------------------------");
1882+
eprintln!("{}", err);
1883+
eprintln!("------------------------------------------");
18841884
}
18851885
}
18861886

18871887
fn error(&self, err: &str) {
18881888
match self.revision {
1889-
Some(rev) => println!("\nerror in revision `{}`: {}", rev, err),
1890-
None => println!("\nerror: {}", err),
1889+
Some(rev) => eprintln!("\nerror in revision `{}`: {}", rev, err),
1890+
None => eprintln!("\nerror: {}", err),
18911891
}
18921892
}
18931893

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

19771977
let suffix =
19781978
self.safe_revision().map_or("nightly".into(), |path| path.to_owned() + "-nightly");
@@ -2082,7 +2082,7 @@ impl<'test> TestCx<'test> {
20822082
.output()
20832083
.unwrap();
20842084
assert!(output.status.success());
2085-
println!("{}", String::from_utf8_lossy(&output.stdout));
2085+
eprintln!("{}", String::from_utf8_lossy(&output.stdout));
20862086
eprintln!("{}", String::from_utf8_lossy(&output.stderr));
20872087
} else {
20882088
use colored::Colorize;
@@ -2496,7 +2496,7 @@ impl<'test> TestCx<'test> {
24962496
)"#
24972497
)
24982498
.replace_all(&output, |caps: &Captures<'_>| {
2499-
println!("{}", &caps[0]);
2499+
eprintln!("{}", &caps[0]);
25002500
caps[0].replace(r"\", "/")
25012501
})
25022502
.replace("\r\n", "\n")
@@ -2601,14 +2601,14 @@ impl<'test> TestCx<'test> {
26012601
if let Err(err) = fs::write(&actual_path, &actual) {
26022602
self.fatal(&format!("failed to write {stream} to `{actual_path:?}`: {err}",));
26032603
}
2604-
println!("Saved the actual {stream} to {actual_path:?}");
2604+
eprintln!("Saved the actual {stream} to {actual_path:?}");
26052605

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

26092609
if !self.config.bless {
26102610
if expected.is_empty() {
2611-
println!("normalized {}:\n{}\n", stream, actual);
2611+
eprintln!("normalized {}:\n{}\n", stream, actual);
26122612
} else {
26132613
self.show_diff(
26142614
stream,
@@ -2631,10 +2631,10 @@ impl<'test> TestCx<'test> {
26312631
if let Err(err) = fs::write(&expected_path, &actual) {
26322632
self.fatal(&format!("failed to write {stream} to `{expected_path:?}`: {err}"));
26332633
}
2634-
println!("Blessing the {stream} of {test_name} in {expected_path:?}");
2634+
eprintln!("Blessing the {stream} of {test_name} in {expected_path:?}");
26352635
}
26362636

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

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

27852785
if self.config.verbose {
2786-
println!("init_incremental_test: incremental_dir={}", incremental_dir.display());
2786+
eprintln!("init_incremental_test: incremental_dir={}", incremental_dir.display());
27872787
}
27882788
}
27892789

@@ -2841,7 +2841,7 @@ impl ProcRes {
28412841
}
28422842
}
28432843

2844-
println!(
2844+
eprintln!(
28452845
"status: {}\ncommand: {}\n{}\n{}\n",
28462846
self.status,
28472847
self.cmdline,
@@ -2852,7 +2852,7 @@ impl ProcRes {
28522852

28532853
pub fn fatal(&self, err: Option<&str>, on_failure: impl FnOnce()) -> ! {
28542854
if let Some(e) = err {
2855-
println!("\nerror: {}", e);
2855+
eprintln!("\nerror: {}", e);
28562856
}
28572857
self.print_info();
28582858
on_failure();

src/tools/compiletest/src/runtest/codegen_units.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ impl TestCx<'_> {
6464
if !missing.is_empty() {
6565
missing.sort();
6666

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

6969
for item in &missing {
70-
println!("{}", item);
70+
eprintln!("{}", item);
7171
}
7272

73-
println!("\n");
73+
eprintln!("\n");
7474
}
7575

7676
if !unexpected.is_empty() {
@@ -80,24 +80,24 @@ impl TestCx<'_> {
8080
sorted
8181
};
8282

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

8585
for item in sorted {
86-
println!("{}", item);
86+
eprintln!("{}", item);
8787
}
8888

89-
println!("\n");
89+
eprintln!("\n");
9090
}
9191

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

9696
for &(ref expected_item, ref actual_item) in &wrong_cgus {
97-
println!("{}", expected_item.name);
98-
println!(" expected: {}", codegen_units_to_str(&expected_item.codegen_units));
99-
println!(" actual: {}", codegen_units_to_str(&actual_item.codegen_units));
100-
println!();
97+
eprintln!("{}", expected_item.name);
98+
eprintln!(" expected: {}", codegen_units_to_str(&expected_item.codegen_units));
99+
eprintln!(" actual: {}", codegen_units_to_str(&actual_item.codegen_units));
100+
eprintln!();
101101
}
102102
}
103103

src/tools/compiletest/src/runtest/debuginfo.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl TestCx<'_> {
260260
cmdline,
261261
};
262262
if adb.kill().is_err() {
263-
println!("Adb process is already finished.");
263+
eprintln!("Adb process is already finished.");
264264
}
265265
} else {
266266
let rust_src_root =
@@ -275,7 +275,7 @@ impl TestCx<'_> {
275275

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

280280
if version > extract_gdb_version("7.4").unwrap() {
281281
// Add the directory containing the pretty printers to
@@ -297,7 +297,7 @@ impl TestCx<'_> {
297297
}
298298
}
299299
_ => {
300-
println!(
300+
eprintln!(
301301
"NOTE: compiletest does not know which version of \
302302
GDB it is using"
303303
);
@@ -392,10 +392,10 @@ impl TestCx<'_> {
392392

393393
match self.config.lldb_version {
394394
Some(ref version) => {
395-
println!("NOTE: compiletest thinks it is using LLDB version {}", version);
395+
eprintln!("NOTE: compiletest thinks it is using LLDB version {}", version);
396396
}
397397
_ => {
398-
println!(
398+
eprintln!(
399399
"NOTE: compiletest does not know which version of \
400400
LLDB it is using"
401401
);

src/tools/compiletest/src/runtest/incremental.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl TestCx<'_> {
3030
assert!(incremental_dir.exists(), "init_incremental_test failed to create incremental dir");
3131

3232
if self.config.verbose {
33-
print!("revision={:?} props={:#?}", revision, self.props);
33+
eprint!("revision={:?} props={:#?}", revision, self.props);
3434
}
3535

3636
if revision.starts_with("cpass") {

src/tools/compiletest/src/runtest/mir_opt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl TestCx<'_> {
8989
}
9090
let expected_string = fs::read_to_string(&expected_file).unwrap();
9191
if dumped_string != expected_string {
92-
print!("{}", write_diff(&expected_string, &dumped_string, 3));
92+
eprint!("{}", write_diff(&expected_string, &dumped_string, 3));
9393
panic!(
9494
"Actual MIR output differs from expected MIR output {}",
9595
expected_file.display()

src/tools/compiletest/src/runtest/rustdoc_json.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl TestCx<'_> {
2929

3030
if !res.status.success() {
3131
self.fatal_proc_rec_with_ctx("jsondocck failed!", &res, |_| {
32-
println!("Rustdoc Output:");
32+
eprintln!("Rustdoc Output:");
3333
proc_res.print_info();
3434
})
3535
}

src/tools/compiletest/src/runtest/ui.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ impl TestCx<'_> {
109109
}
110110

111111
if errors > 0 {
112-
println!("To update references, rerun the tests and pass the `--bless` flag");
112+
eprintln!("To update references, rerun the tests and pass the `--bless` flag");
113113
let relative_path_to_file =
114114
self.testpaths.relative_dir.join(self.testpaths.file.file_name().unwrap());
115-
println!(
115+
eprintln!(
116116
"To only update this specific test, also pass `--test-args {}`",
117117
relative_path_to_file.display(),
118118
);

src/tools/compiletest/src/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn path_div() -> &'static str {
3030
pub fn logv(config: &Config, s: String) {
3131
debug!("{}", s);
3232
if config.verbose {
33-
println!("{}", s);
33+
eprintln!("{}", s);
3434
}
3535
}
3636

0 commit comments

Comments
 (0)