add info to rust-ldd tests failures

This commit is contained in:
lcnr 2024-05-24 15:46:42 +00:00
parent 86cbabbb9d
commit aa8f995b89
3 changed files with 24 additions and 17 deletions

View File

@ -17,8 +17,9 @@ fn main() {
.input("main.rs")
.run();
assert!(
find_lld_version_in_logs(output),
"the LLD version string should be present in the output logs"
find_lld_version_in_logs(&output),
"the LLD version string should be present in the output logs:\n{}",
std::str::from_utf8(&output.stderr).unwrap()
);
// But it can still be disabled by turning the linker feature off.
@ -29,12 +30,13 @@ fn main() {
.input("main.rs")
.run();
assert!(
!find_lld_version_in_logs(output),
"the LLD version string should not be present in the output logs"
!find_lld_version_in_logs(&output),
"the LLD version string should not be present in the output logs:\n{}",
std::str::from_utf8(&output.stderr).unwrap()
);
}
fn find_lld_version_in_logs(output: Output) -> bool {
fn find_lld_version_in_logs(output: &Output) -> bool {
let lld_version_re = Regex::new(r"^LLD [0-9]+\.[0-9]+\.[0-9]+").unwrap();
let stderr = std::str::from_utf8(&output.stderr).unwrap();
stderr.lines().any(|line| lld_version_re.is_match(line))

View File

@ -23,8 +23,9 @@ fn main() {
.input("lib.rs")
.run();
assert!(
find_lld_version_in_logs(output),
"the LLD version string should be present in the output logs"
find_lld_version_in_logs(&output),
"the LLD version string should be present in the output logs:\n{}",
std::str::from_utf8(&output.stderr).unwrap()
);
// But it can also be disabled via linker features.
@ -37,12 +38,13 @@ fn main() {
.input("lib.rs")
.run();
assert!(
!find_lld_version_in_logs(output),
"the LLD version string should not be present in the output logs"
!find_lld_version_in_logs(&output),
"the LLD version string should not be present in the output logs:\n{}",
std::str::from_utf8(&output.stderr).unwrap()
);
}
fn find_lld_version_in_logs(output: Output) -> bool {
fn find_lld_version_in_logs(output: &Output) -> bool {
let lld_version_re = Regex::new(r"^LLD [0-9]+\.[0-9]+\.[0-9]+").unwrap();
let stderr = std::str::from_utf8(&output.stderr).unwrap();
stderr.lines().any(|line| lld_version_re.is_match(line))

View File

@ -21,8 +21,9 @@ fn main() {
.input("main.rs")
.run();
assert!(
find_lld_version_in_logs(output),
"the LLD version string should be present in the output logs"
find_lld_version_in_logs(&output),
"the LLD version string should be present in the output logs:\n{}",
std::str::from_utf8(&output.stderr).unwrap()
);
// It should not be used when we explictly opt-out of lld.
@ -33,8 +34,9 @@ fn main() {
.input("main.rs")
.run();
assert!(
!find_lld_version_in_logs(output),
"the LLD version string should not be present in the output logs"
!find_lld_version_in_logs(&output),
"the LLD version string should not be present in the output logs:\n{}",
std::str::from_utf8(&output.stderr).unwrap()
);
// While we're here, also check that the last linker feature flag "wins" when passed multiple
@ -50,12 +52,13 @@ fn main() {
.input("main.rs")
.run();
assert!(
find_lld_version_in_logs(output),
"the LLD version string should be present in the output logs"
find_lld_version_in_logs(&output),
"the LLD version string should be present in the output logs:\n{}",
std::str::from_utf8(&output.stderr).unwrap()
);
}
fn find_lld_version_in_logs(output: Output) -> bool {
fn find_lld_version_in_logs(output: &Output) -> bool {
let lld_version_re = Regex::new(r"^LLD [0-9]+\.[0-9]+\.[0-9]+").unwrap();
let stderr = std::str::from_utf8(&output.stderr).unwrap();
stderr.lines().any(|line| lld_version_re.is_match(line))