Skip to content

Commit cc137ab

Browse files
committed
Auto merge of #523 - Zeegomo:fix-experiment-page, r=pietroalbini
Fix experiment page This fixes the extremely long list of results in the experiment page by grouping `CompilerError` and `DependsOn` under a single counter. `ResultName` and `ResultColor` are also moved into a separate file. This is done because those traits are not used only by `html` module anymore (especially if we consider future updates on markdown report). They could have been moved to `mod.rs` but I feel like this way it's cleaner and we avoid having too many things on that file.
2 parents f190933 + 2a30b9d commit cc137ab

File tree

4 files changed

+104
-91
lines changed

4 files changed

+104
-91
lines changed

src/report/display.rs

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
use crate::prelude::*;
2+
use crate::report::Comparison;
3+
use crate::results::{BrokenReason, FailureReason, TestResult};
4+
5+
pub trait ResultName {
6+
fn name(&self) -> String;
7+
}
8+
9+
impl ResultName for FailureReason {
10+
fn name(&self) -> String {
11+
match self {
12+
FailureReason::Unknown => "failed".into(),
13+
FailureReason::Timeout => "timed out".into(),
14+
FailureReason::OOM => "OOM".into(),
15+
FailureReason::ICE => "ICE".into(),
16+
FailureReason::CompilerError(_) => "compiler error".into(),
17+
FailureReason::DependsOn(_) => "faulty deps".into(),
18+
}
19+
}
20+
}
21+
22+
impl ResultName for BrokenReason {
23+
fn name(&self) -> String {
24+
match self {
25+
BrokenReason::Unknown => "broken crate".into(),
26+
BrokenReason::CargoToml => "broken Cargo.toml".into(),
27+
BrokenReason::Yanked => "deps yanked".into(),
28+
BrokenReason::MissingGitRepository => "missing repo".into(),
29+
}
30+
}
31+
}
32+
33+
impl ResultName for TestResult {
34+
fn name(&self) -> String {
35+
match self {
36+
TestResult::BrokenCrate(reason) => reason.name(),
37+
TestResult::BuildFail(reason) => format!("build {}", reason.name()),
38+
TestResult::TestFail(reason) => format!("test {}", reason.name()),
39+
TestResult::TestSkipped => "test skipped".into(),
40+
TestResult::TestPass => "test passed".into(),
41+
TestResult::Error => "error".into(),
42+
TestResult::Skipped => "skipped".into(),
43+
}
44+
}
45+
}
46+
47+
#[derive(Serialize)]
48+
pub enum Color {
49+
Single(&'static str),
50+
Striped(&'static str, &'static str),
51+
}
52+
53+
pub trait ResultColor {
54+
fn color(&self) -> Color;
55+
}
56+
57+
impl ResultColor for Comparison {
58+
fn color(&self) -> Color {
59+
match self {
60+
Comparison::Regressed => Color::Single("#db3026"),
61+
Comparison::Fixed => Color::Single("#5630db"),
62+
Comparison::Skipped => Color::Striped("#494b4a", "#555555"),
63+
Comparison::Unknown => Color::Single("#494b4a"),
64+
Comparison::SameBuildFail => Color::Single("#65461e"),
65+
Comparison::SameTestFail => Color::Single("#788843"),
66+
Comparison::SameTestSkipped => Color::Striped("#72a156", "#80b65f"),
67+
Comparison::SameTestPass => Color::Single("#72a156"),
68+
Comparison::Error => Color::Single("#d77026"),
69+
Comparison::Broken => Color::Single("#44176e"),
70+
Comparison::SpuriousRegressed => Color::Striped("#db3026", "#d5433b"),
71+
Comparison::SpuriousFixed => Color::Striped("#5630db", "#5d3dcf"),
72+
}
73+
}
74+
}
75+
76+
impl ResultColor for TestResult {
77+
fn color(&self) -> Color {
78+
match self {
79+
TestResult::BrokenCrate(_) => Color::Single("#44176e"),
80+
TestResult::BuildFail(_) => Color::Single("#db3026"),
81+
TestResult::TestFail(_) => Color::Single("#65461e"),
82+
TestResult::TestSkipped | TestResult::TestPass => Color::Single("#62a156"),
83+
TestResult::Error => Color::Single("#d77026"),
84+
TestResult::Skipped => Color::Single("#494b4a"),
85+
}
86+
}
87+
}

src/report/html.rs

Lines changed: 4 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,12 @@
11
use crate::assets;
22
use crate::experiments::Experiment;
33
use crate::prelude::*;
4-
use crate::report::{archives::Archive, Comparison, ReportWriter, TestResults};
5-
use crate::results::{BrokenReason, EncodingType, FailureReason, TestResult};
4+
use crate::report::{
5+
archives::Archive, Color, Comparison, ReportWriter, ResultColor, ResultName, TestResults,
6+
};
7+
use crate::results::EncodingType;
68
use std::collections::HashMap;
79

8-
#[derive(Serialize)]
9-
enum Color {
10-
Single(&'static str),
11-
Striped(&'static str, &'static str),
12-
}
13-
14-
trait ResultColor {
15-
fn color(&self) -> Color;
16-
}
17-
18-
impl ResultColor for Comparison {
19-
fn color(&self) -> Color {
20-
match self {
21-
Comparison::Regressed => Color::Single("#db3026"),
22-
Comparison::Fixed => Color::Single("#5630db"),
23-
Comparison::Skipped => Color::Striped("#494b4a", "#555555"),
24-
Comparison::Unknown => Color::Single("#494b4a"),
25-
Comparison::SameBuildFail => Color::Single("#65461e"),
26-
Comparison::SameTestFail => Color::Single("#788843"),
27-
Comparison::SameTestSkipped => Color::Striped("#72a156", "#80b65f"),
28-
Comparison::SameTestPass => Color::Single("#72a156"),
29-
Comparison::Error => Color::Single("#d77026"),
30-
Comparison::Broken => Color::Single("#44176e"),
31-
Comparison::SpuriousRegressed => Color::Striped("#db3026", "#d5433b"),
32-
Comparison::SpuriousFixed => Color::Striped("#5630db", "#5d3dcf"),
33-
}
34-
}
35-
}
36-
37-
impl ResultColor for TestResult {
38-
fn color(&self) -> Color {
39-
match self {
40-
TestResult::BrokenCrate(_) => Color::Single("#44176e"),
41-
TestResult::BuildFail(_) => Color::Single("#db3026"),
42-
TestResult::TestFail(_) => Color::Single("#65461e"),
43-
TestResult::TestSkipped | TestResult::TestPass => Color::Single("#62a156"),
44-
TestResult::Error => Color::Single("#d77026"),
45-
TestResult::Skipped => Color::Single("#494b4a"),
46-
}
47-
}
48-
}
49-
50-
trait ResultName {
51-
fn name(&self) -> String;
52-
}
53-
54-
impl ResultName for FailureReason {
55-
fn name(&self) -> String {
56-
match self {
57-
FailureReason::Unknown => "failed".into(),
58-
FailureReason::Timeout => "timed out".into(),
59-
FailureReason::OOM => "OOM".into(),
60-
FailureReason::ICE => "ICE".into(),
61-
FailureReason::CompilerError(_) => "compiler error".into(),
62-
FailureReason::DependsOn(_) => "faulty deps".into(),
63-
}
64-
}
65-
}
66-
67-
impl ResultName for BrokenReason {
68-
fn name(&self) -> String {
69-
match self {
70-
BrokenReason::Unknown => "broken crate".into(),
71-
BrokenReason::CargoToml => "broken Cargo.toml".into(),
72-
BrokenReason::Yanked => "deps yanked".into(),
73-
BrokenReason::MissingGitRepository => "missing repo".into(),
74-
}
75-
}
76-
}
77-
78-
impl ResultName for TestResult {
79-
fn name(&self) -> String {
80-
match self {
81-
TestResult::BrokenCrate(reason) => reason.name(),
82-
TestResult::BuildFail(reason) => format!("build {}", reason.name()),
83-
TestResult::TestFail(reason) => format!("test {}", reason.name()),
84-
TestResult::TestSkipped => "test skipped".into(),
85-
TestResult::TestPass => "test passed".into(),
86-
TestResult::Error => "error".into(),
87-
TestResult::Skipped => "skipped".into(),
88-
}
89-
}
90-
}
91-
9210
#[derive(Serialize)]
9311
struct NavbarItem {
9412
label: &'static str,

src/report/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::config::Config;
22
use crate::crates::Crate;
33
use crate::experiments::Experiment;
44
use crate::prelude::*;
5-
use crate::results::{EncodedLog, EncodingType, ReadResults, TestResult};
5+
use crate::results::{EncodedLog, EncodingType, FailureReason, ReadResults, TestResult};
66
use crate::toolchain::Toolchain;
77
use crate::utils;
88
use mime::{self, Mime};
@@ -19,9 +19,11 @@ use std::io::{self, Read};
1919
use std::path::{Path, PathBuf};
2020

2121
mod archives;
22+
mod display;
2223
mod html;
2324
mod s3;
2425

26+
pub use self::display::{Color, ResultColor, ResultName};
2527
pub use self::s3::{get_client_for_bucket, S3Prefix, S3Writer};
2628

2729
pub(crate) const REPORT_ENCODE_SET: AsciiSet = percent_encoding::CONTROLS
@@ -361,7 +363,6 @@ fn compare(
361363
r1: Option<&TestResult>,
362364
r2: Option<&TestResult>,
363365
) -> Comparison {
364-
use crate::results::FailureReason;
365366
use crate::results::TestResult::*;
366367

367368
match (r1, r2) {

src/server/routes/ui/experiments.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use crate::experiments::{Experiment, Mode, Status};
22
use crate::prelude::*;
3-
use crate::results::TestResult;
3+
use crate::report::ResultName;
44
use crate::server::routes::ui::{render_template, LayoutContext};
55
use crate::server::{Data, HttpError};
66
use chrono::{Duration, SecondsFormat, Utc};
77
use chrono_humanize::{Accuracy, HumanTime, Tense};
88
use http::Response;
99
use hyper::Body;
10+
use std::collections::HashMap;
1011
use std::sync::Arc;
1112

1213
#[derive(Serialize)]
@@ -121,7 +122,7 @@ struct ExperimentExt {
121122

122123
total_jobs: u32,
123124
completed_jobs: u32,
124-
result_counts: Vec<(TestResult, u32)>,
125+
result_counts: Vec<(String, u32)>,
125126
duration: Option<String>,
126127
estimated_end: Option<String>,
127128
average_job_duration: Option<String>,
@@ -136,7 +137,13 @@ struct ExperimentContext {
136137
pub fn endpoint_experiment(name: String, data: Arc<Data>) -> Fallible<Response<Body>> {
137138
if let Some(ex) = Experiment::get(&data.db, &name)? {
138139
let (completed_jobs, total_jobs) = ex.raw_progress(&data.db)?;
139-
let result_counts = ex.get_result_counts(&data.db)?;
140+
// this is done to avoid having tons of different test result types in the experiment page
141+
// all CompilerError and DependsOn failures are grouped together
142+
let mut result_counts = HashMap::new();
143+
for (res, count) in ex.get_result_counts(&data.db)? {
144+
*result_counts.entry(res.name()).or_default() += count;
145+
}
146+
let result_counts = result_counts.into_iter().collect::<Vec<_>>();
140147

141148
let (duration, estimated_end, average_job_duration) = if completed_jobs > 0
142149
&& total_jobs > 0

0 commit comments

Comments
 (0)