Skip to content

Commit 4b31033

Browse files
committed
Add a note about how to find tests that haven't been executed anywhere.
1 parent a326afd commit 4b31033

File tree

2 files changed

+22
-55
lines changed

2 files changed

+22
-55
lines changed

Diff for: src/ci/citool/src/test_dashboard/mod.rs

+10-50
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,13 @@ use crate::jobs::JobDatabase;
1010
use crate::metrics::{JobMetrics, JobName, download_auto_job_metrics, get_test_suites};
1111
use crate::utils::normalize_path_delimiters;
1212

13-
pub struct TestInfo {
14-
name: String,
15-
jobs: Vec<JobTestResult>,
16-
}
17-
18-
struct JobTestResult {
19-
job_name: String,
20-
outcome: TestOutcome,
21-
}
22-
23-
#[derive(Default)]
24-
struct TestSuiteInfo {
25-
name: String,
26-
tests: BTreeMap<String, TestInfo>,
27-
}
28-
2913
/// Generate a set of HTML files into a directory that contain a dashboard of test results.
3014
pub fn generate_test_dashboard(
3115
db: JobDatabase,
3216
current: &str,
3317
output_dir: &Path,
3418
) -> anyhow::Result<()> {
3519
let metrics = download_auto_job_metrics(&db, None, current)?;
36-
3720
let suites = gather_test_suites(&metrics);
3821

3922
std::fs::create_dir_all(output_dir)?;
@@ -52,27 +35,27 @@ fn write_page<T: Template>(dir: &Path, name: &str, template: &T) -> anyhow::Resu
5235

5336
fn gather_test_suites(job_metrics: &HashMap<JobName, JobMetrics>) -> TestSuites {
5437
struct CoarseTestSuite<'a> {
55-
kind: TestSuiteKind,
5638
tests: BTreeMap<String, Test<'a>>,
5739
}
5840

5941
let mut suites: HashMap<String, CoarseTestSuite> = HashMap::new();
6042

6143
// First, gather tests from all jobs, stages and targets, and aggregate them per suite
44+
// Only work with compiletest suites.
6245
for (job, metrics) in job_metrics {
6346
let test_suites = get_test_suites(&metrics.current);
6447
for suite in test_suites {
65-
let (suite_name, stage, target, kind) = match &suite.metadata {
66-
TestSuiteMetadata::CargoPackage { crates, stage, target, .. } => {
67-
(crates.join(","), *stage, target, TestSuiteKind::Cargo)
48+
let (suite_name, stage, target) = match &suite.metadata {
49+
TestSuiteMetadata::CargoPackage { .. } => {
50+
continue;
6851
}
6952
TestSuiteMetadata::Compiletest { suite, stage, target, .. } => {
70-
(suite.clone(), *stage, target, TestSuiteKind::Compiletest)
53+
(suite.clone(), *stage, target)
7154
}
7255
};
7356
let suite_entry = suites
7457
.entry(suite_name.clone())
75-
.or_insert_with(|| CoarseTestSuite { kind, tests: Default::default() });
58+
.or_insert_with(|| CoarseTestSuite { tests: Default::default() });
7659
let test_metadata = TestMetadata { job, stage, target };
7760

7861
for test in &suite.tests {
@@ -98,29 +81,13 @@ fn gather_test_suites(job_metrics: &HashMap<JobName, JobMetrics>) -> TestSuites
9881

9982
// Then, split the suites per directory
10083
let mut suites = suites.into_iter().collect::<Vec<_>>();
101-
suites.sort_by(|a, b| a.1.kind.cmp(&b.1.kind).then_with(|| a.0.cmp(&b.0)));
84+
suites.sort_by(|a, b| a.0.cmp(&b.0));
10285

10386
let mut target_suites = vec![];
10487
for (suite_name, suite) in suites {
105-
let suite = match suite.kind {
106-
TestSuiteKind::Compiletest => TestSuite {
107-
name: suite_name.clone(),
108-
kind: TestSuiteKind::Compiletest,
109-
group: build_test_group(&suite_name, suite.tests),
110-
},
111-
TestSuiteKind::Cargo => {
112-
let mut tests: Vec<_> = suite.tests.into_iter().collect();
113-
tests.sort_by(|a, b| a.0.cmp(&b.0));
114-
TestSuite {
115-
name: format!("[cargo] {}", suite_name.clone()),
116-
kind: TestSuiteKind::Cargo,
117-
group: TestGroup {
118-
name: suite_name,
119-
root_tests: tests.into_iter().map(|t| t.1).collect(),
120-
groups: vec![],
121-
},
122-
}
123-
}
88+
let suite = TestSuite {
89+
name: suite_name.clone(),
90+
group: build_test_group(&suite_name, suite.tests),
12491
};
12592
target_suites.push(suite);
12693
}
@@ -187,7 +154,6 @@ impl<'a> TestSuites<'a> {
187154
#[derive(serde::Serialize)]
188155
struct TestSuite<'a> {
189156
name: String,
190-
kind: TestSuiteKind,
191157
group: TestGroup<'a>,
192158
}
193159

@@ -225,12 +191,6 @@ impl<'a> TestGroup<'a> {
225191
}
226192
}
227193

228-
#[derive(PartialEq, Eq, PartialOrd, Ord, serde::Serialize)]
229-
enum TestSuiteKind {
230-
Compiletest,
231-
Cargo,
232-
}
233-
234194
#[derive(Template)]
235195
#[template(path = "test_suites.askama")]
236196
struct TestSuitesPage<'a> {

Diff for: src/ci/citool/templates/test_suites.askama

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
{% extends "layout.askama" %}
22

33
{% block content %}
4-
<h1>Rust CI Test Dashboard</h1>
4+
<h1>Rust CI test dashboard</h1>
55
<div class="test-suites">
66
<div class="summary">
7-
<span>Total tests: {{ test_count }}</span>
7+
<div>
8+
<div class="test-count">Total tests: {{ test_count }}</div>
9+
<div>
10+
To find tests that haven't been executed anywhere, click on "Open all" and search for "(0 passed".
11+
</div>
12+
</div>
813
<div>
914
<button onclick="openAll()">Open all</button>
1015
<button onclick="closeAll()">Close all</button>
@@ -13,9 +18,7 @@
1318

1419
<ul>
1520
{% for suite in suites.suites %}
16-
{% if suite.kind == TestSuiteKind::Compiletest %}
17-
{{ suite.group|safe }}
18-
{% endif %}
21+
{{ suite.group|safe }}
1922
{% endfor %}
2023
</ul>
2124
</div>
@@ -33,6 +36,10 @@ h1 {
3336
justify-content: space-between;
3437
}
3538

39+
.test-count {
40+
font-size: 1.2em;
41+
}
42+
3643
.test-suites {
3744
background: white;
3845
border-radius: 8px;

0 commit comments

Comments
 (0)