Skip to content

Commit e305908

Browse files
committed
add long_name for ResultName
1 parent ea99817 commit e305908

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

src/report/display.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::results::{BrokenReason, FailureReason, TestResult};
44

55
pub trait ResultName {
66
fn name(&self) -> String;
7+
fn long_name(&self) -> String;
78
}
89

910
impl ResultName for FailureReason {
@@ -17,6 +18,16 @@ impl ResultName for FailureReason {
1718
FailureReason::DependsOn(_) => "faulty deps".into(),
1819
}
1920
}
21+
22+
fn long_name(&self) -> String {
23+
match self {
24+
FailureReason::CompilerError(_) | FailureReason::DependsOn(_) => self.to_string(),
25+
FailureReason::Unknown
26+
| FailureReason::Timeout
27+
| FailureReason::OOM
28+
| FailureReason::ICE => self.name(),
29+
}
30+
}
2031
}
2132

2233
impl ResultName for BrokenReason {
@@ -28,6 +39,10 @@ impl ResultName for BrokenReason {
2839
BrokenReason::MissingGitRepository => "missing repo".into(),
2940
}
3041
}
42+
43+
fn long_name(&self) -> String {
44+
self.name()
45+
}
3146
}
3247

3348
impl ResultName for TestResult {
@@ -42,6 +57,18 @@ impl ResultName for TestResult {
4257
TestResult::Skipped => "skipped".into(),
4358
}
4459
}
60+
61+
fn long_name(&self) -> String {
62+
match self {
63+
TestResult::BuildFail(reason) => format!("build {}", reason.long_name()),
64+
TestResult::TestFail(reason) => format!("test {}", reason.long_name()),
65+
TestResult::BrokenCrate(reason) => reason.long_name(),
66+
TestResult::TestSkipped
67+
| TestResult::TestPass
68+
| TestResult::Error
69+
| TestResult::Skipped => self.name(),
70+
}
71+
}
4572
}
4673

4774
#[derive(Serialize)]

src/report/html.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::report::{
55
analyzer::ReportCrates, archives::Archive, Color, Comparison, CrateResult, ReportWriter,
66
ResultColor, ResultName, TestResults,
77
};
8-
use crate::results::{EncodingType, FailureReason, TestResult};
8+
use crate::results::EncodingType;
99
use indexmap::IndexMap;
1010

1111
#[derive(Serialize)]
@@ -170,12 +170,7 @@ fn write_report<W: ReportWriter>(
170170
.into_iter()
171171
.map(|(res, krates)| {
172172
(
173-
if let TestResult::BuildFail(FailureReason::CompilerError(_)) = res
174-
{
175-
res.to_string()
176-
} else {
177-
res.name()
178-
},
173+
res.long_name(),
179174
krates
180175
.into_iter()
181176
.map(|result| to_html_crate_result(result))

0 commit comments

Comments
 (0)