Skip to content

Commit 2372561

Browse files
committed
compiletest: println! -> eprintln!
1 parent 3fadb87 commit 2372561

File tree

9 files changed

+54
-54
lines changed

9 files changed

+54
-54
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

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

504-
println!(
504+
eprintln!(
505505
"Some tests failed in compiletest suite={}{} mode={} host={} target={}",
506506
config.suite,
507507
config

src/tools/compiletest/src/runtest.rs

+25-25
Original file line numberDiff line numberDiff line change
@@ -771,20 +771,20 @@ impl<'test> TestCx<'test> {
771771
unexpected.len(),
772772
not_found.len()
773773
));
774-
println!("status: {}\ncommand: {}\n", proc_res.status, proc_res.cmdline);
774+
eprintln!("status: {}\ncommand: {}\n", proc_res.status, proc_res.cmdline);
775775
if !unexpected.is_empty() {
776-
println!("{}", "--- unexpected errors (from JSON output) ---".green());
776+
eprintln!("{}", "--- unexpected errors (from JSON output) ---".green());
777777
for error in &unexpected {
778-
println!("{}", error.render_for_expected());
778+
eprintln!("{}", error.render_for_expected());
779779
}
780-
println!("{}", "---".green());
780+
eprintln!("{}", "---".green());
781781
}
782782
if !not_found.is_empty() {
783-
println!("{}", "--- not found errors (from test file) ---".red());
783+
eprintln!("{}", "--- not found errors (from test file) ---".red());
784784
for error in &not_found {
785-
println!("{}", error.render_for_expected());
785+
eprintln!("{}", error.render_for_expected());
786786
}
787-
println!("{}", "---\n".red());
787+
eprintln!("{}", "---\n".red());
788788
}
789789
panic!("errors differ from expected");
790790
}
@@ -1873,18 +1873,18 @@ impl<'test> TestCx<'test> {
18731873

18741874
fn maybe_dump_to_stdout(&self, out: &str, err: &str) {
18751875
if self.config.verbose {
1876-
println!("------stdout------------------------------");
1877-
println!("{}", out);
1878-
println!("------stderr------------------------------");
1879-
println!("{}", err);
1880-
println!("------------------------------------------");
1876+
eprintln!("------stdout------------------------------");
1877+
eprintln!("{}", out);
1878+
eprintln!("------stderr------------------------------");
1879+
eprintln!("{}", err);
1880+
eprintln!("------------------------------------------");
18811881
}
18821882
}
18831883

18841884
fn error(&self, err: &str) {
18851885
match self.revision {
1886-
Some(rev) => println!("\nerror in revision `{}`: {}", rev, err),
1887-
None => println!("\nerror: {}", err),
1886+
Some(rev) => eprintln!("\nerror in revision `{}`: {}", rev, err),
1887+
None => eprintln!("\nerror: {}", err),
18881888
}
18891889
}
18901890

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

19741974
let suffix =
19751975
self.safe_revision().map_or("nightly".into(), |path| path.to_owned() + "-nightly");
@@ -2079,7 +2079,7 @@ impl<'test> TestCx<'test> {
20792079
.output()
20802080
.unwrap();
20812081
assert!(output.status.success());
2082-
println!("{}", String::from_utf8_lossy(&output.stdout));
2082+
eprintln!("{}", String::from_utf8_lossy(&output.stdout));
20832083
eprintln!("{}", String::from_utf8_lossy(&output.stderr));
20842084
} else {
20852085
use colored::Colorize;
@@ -2479,7 +2479,7 @@ impl<'test> TestCx<'test> {
24792479
)"#
24802480
)
24812481
.replace_all(&output, |caps: &Captures<'_>| {
2482-
println!("{}", &caps[0]);
2482+
eprintln!("{}", &caps[0]);
24832483
caps[0].replace(r"\", "/")
24842484
})
24852485
.replace("\r\n", "\n")
@@ -2578,16 +2578,16 @@ impl<'test> TestCx<'test> {
25782578
if let Err(err) = fs::write(&actual_path, &actual) {
25792579
self.fatal(&format!("failed to write {stream} to `{actual_path:?}`: {err}",));
25802580
}
2581-
println!("Saved the actual {stream} to {actual_path:?}");
2581+
eprintln!("Saved the actual {stream} to {actual_path:?}");
25822582

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

25862586
if !self.config.bless {
25872587
if expected.is_empty() {
2588-
println!("normalized {}:\n{}\n", stream, actual);
2588+
eprintln!("normalized {}:\n{}\n", stream, actual);
25892589
} else {
2590-
println!("diff of {stream}:\n");
2590+
eprintln!("diff of {stream}:\n");
25912591
if let Some(diff_command) = self.config.diff_command.as_deref() {
25922592
let mut args = diff_command.split_whitespace();
25932593
let name = args.next().unwrap();
@@ -2622,10 +2622,10 @@ impl<'test> TestCx<'test> {
26222622
if let Err(err) = fs::write(&expected_path, &actual) {
26232623
self.fatal(&format!("failed to write {stream} to `{expected_path:?}`: {err}"));
26242624
}
2625-
println!("Blessing the {stream} of {test_name} in {expected_path:?}");
2625+
eprintln!("Blessing the {stream} of {test_name} in {expected_path:?}");
26262626
}
26272627

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

26302630
if self.config.bless { 0 } else { 1 }
26312631
}
@@ -2704,7 +2704,7 @@ impl<'test> TestCx<'test> {
27042704
fs::create_dir_all(&incremental_dir).unwrap();
27052705

27062706
if self.config.verbose {
2707-
println!("init_incremental_test: incremental_dir={}", incremental_dir.display());
2707+
eprintln!("init_incremental_test: incremental_dir={}", incremental_dir.display());
27082708
}
27092709
}
27102710

@@ -2762,7 +2762,7 @@ impl ProcRes {
27622762
}
27632763
}
27642764

2765-
println!(
2765+
eprintln!(
27662766
"status: {}\ncommand: {}\n{}\n{}\n",
27672767
self.status,
27682768
self.cmdline,
@@ -2773,7 +2773,7 @@ impl ProcRes {
27732773

27742774
pub fn fatal(&self, err: Option<&str>, on_failure: impl FnOnce()) -> ! {
27752775
if let Some(e) = err {
2776-
println!("\nerror: {}", e);
2776+
eprintln!("\nerror: {}", e);
27772777
}
27782778
self.print_info();
27792779
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/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)