Add set_backtrace_level helper function to run_make_support
This commit is contained in:
parent
f88c647cda
commit
8a6bc13cfe
@ -100,6 +100,12 @@ pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Adjust the backtrace level, displaying more detailed information at higher levels.
|
||||||
|
pub fn set_backtrace_level<R: AsRef<OsStr>>(&mut self, level: R) -> &mut Self {
|
||||||
|
self.cmd.env("RUST_BACKTRACE", level);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Specify path to the output file. Equivalent to `-o`` in rustc.
|
/// Specify path to the output file. Equivalent to `-o`` in rustc.
|
||||||
pub fn output<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
|
pub fn output<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
|
||||||
self.cmd.arg("-o");
|
self.cmd.arg("-o");
|
||||||
|
@ -4,26 +4,37 @@
|
|||||||
// was shortened down to an appropriate length.
|
// was shortened down to an appropriate length.
|
||||||
// See https://github.com/rust-lang/rust/issues/107910
|
// See https://github.com/rust-lang/rust/issues/107910
|
||||||
|
|
||||||
|
//@ ignore-windows
|
||||||
|
// Reason: the assert_eq! on line 32 fails, as error output on Windows is different.
|
||||||
|
|
||||||
use run_make_support::rustc;
|
use run_make_support::rustc;
|
||||||
use std::env;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
env::set_var("RUST_BACKTRACE", "1");
|
let rust_test_1 =
|
||||||
let mut rust_test_1 = rustc().input("src/lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
|
rustc().set_backtrace_level("1").input("src/lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
|
||||||
env::set_var("RUST_BACKTRACE", "full");
|
let rust_test_2 = rustc()
|
||||||
let mut rust_test_2 = rustc().input("src/lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
|
.set_backtrace_level("full")
|
||||||
let rust_test_log_1 = rust_test_1.stderr_utf8().push_str(&rust_test_1.stdout_utf8()).as_str();
|
.input("src/lib.rs")
|
||||||
let rust_test_log_2 = rust_test_2.stderr_utf8().push_str(&rust_test_2.stdout_utf8()).as_str();
|
.arg("-Ztreat-err-as-bug=1")
|
||||||
|
.run_fail();
|
||||||
|
|
||||||
|
let mut rust_test_log_1 = rust_test_1.stderr_utf8();
|
||||||
|
rust_test_log_1.push_str(&rust_test_1.stdout_utf8());
|
||||||
|
let rust_test_log_1 = rust_test_log_1.as_str();
|
||||||
|
|
||||||
|
let mut rust_test_log_2 = rust_test_2.stderr_utf8();
|
||||||
|
rust_test_log_2.push_str(&rust_test_2.stdout_utf8());
|
||||||
|
let rust_test_log_2 = rust_test_log_2.as_str();
|
||||||
|
|
||||||
let rustc_query_count_full = count_lines_with(rust_test_log_2, "rustc_query_");
|
let rustc_query_count_full = count_lines_with(rust_test_log_2, "rustc_query_");
|
||||||
|
|
||||||
assert!(
|
assert!(rust_test_log_1.lines().count() < rust_test_log_2.lines().count());
|
||||||
rust_test_log_1.lines().count() < rust_test_log_2.lines().count()
|
assert_eq!(
|
||||||
&& count_lines_with(rust_test_log_2, "__rust_begin_short_backtrace")
|
count_lines_with(rust_test_log_2, "__rust_begin_short_backtrace"),
|
||||||
== count_lines_with(rust_test_log_2, "__rust_end_short_backtrace")
|
count_lines_with(rust_test_log_2, "__rust_end_short_backtrace")
|
||||||
&& count_lines_with(rust_test_log_1, "rustc_query_") + 5 < rustc_query_count_full
|
|
||||||
&& rustc_query_count_full > 5
|
|
||||||
);
|
);
|
||||||
|
assert!(count_lines_with(rust_test_log_1, "rustc_query_") + 5 < rustc_query_count_full);
|
||||||
|
assert!(rustc_query_count_full > 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn count_lines_with(s: &str, search: &str) -> usize {
|
fn count_lines_with(s: &str, search: &str) -> usize {
|
||||||
|
Loading…
Reference in New Issue
Block a user