Skip to content

Commit b18e373

Browse files
committed
Reduce duplicated test prefixes in nested subdirectories
`assembly/asm` contained a test named `asm/aarch64-el2vmsa.rs`, while it should have been only `arch64-el2vmsa.rs`.
1 parent 65ce38a commit b18e373

File tree

2 files changed

+17
-25
lines changed

2 files changed

+17
-25
lines changed

src/ci/citool/src/test_dashboard.rs

+14-22
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ fn gather_test_suites(job_metrics: &HashMap<JobName, JobMetrics>) -> TestSuites
6464
Some((name, variant)) => (name.to_string(), variant.to_string()),
6565
None => (test_name, "".to_string()),
6666
};
67-
let test_entry = suite_entry.tests.entry(test_name.clone()).or_insert_with(|| {
68-
Test { name: test_name.clone(), revisions: Default::default() }
69-
});
67+
let test_entry = suite_entry
68+
.tests
69+
.entry(test_name.clone())
70+
.or_insert_with(|| Test { revisions: Default::default() });
7071
let variant_entry = test_entry
7172
.revisions
7273
.entry(variant_name)
@@ -91,16 +92,12 @@ fn gather_test_suites(job_metrics: &HashMap<JobName, JobMetrics>) -> TestSuites
9192
let mut suites = suites.into_iter().collect::<Vec<_>>();
9293
suites.sort_by(|a, b| a.0.cmp(&b.0));
9394

94-
let mut target_suites = vec![];
95-
for (suite_name, suite) in suites {
96-
let suite = TestSuite {
97-
name: suite_name.clone(),
98-
group: build_test_group(&suite_name, suite.tests),
99-
};
100-
target_suites.push(suite);
101-
}
95+
let suites = suites
96+
.into_iter()
97+
.map(|(suite_name, suite)| TestSuite { group: build_test_group(&suite_name, suite.tests) })
98+
.collect();
10299

103-
TestSuites { suites: target_suites }
100+
TestSuites { suites }
104101
}
105102

106103
/// Recursively expand a test group based on filesystem hierarchy.
@@ -115,7 +112,7 @@ fn build_test_group<'a>(name: &str, tests: BTreeMap<String, Test<'a>>) -> TestGr
115112

116113
if components.peek().is_none() {
117114
// This is a root test
118-
root_tests.push(test);
115+
root_tests.push((name, test));
119116
} else {
120117
// This is a test in a nested directory
121118
let subdir_tests =
@@ -148,7 +145,6 @@ fn normalize_test_name(name: &str, suite_name: &str) -> String {
148145
name.trim_start_matches("/").to_string()
149146
}
150147

151-
#[derive(serde::Serialize)]
152148
struct TestSuites<'a> {
153149
suites: Vec<TestSuite<'a>>,
154150
}
@@ -159,21 +155,16 @@ impl<'a> TestSuites<'a> {
159155
}
160156
}
161157

162-
#[derive(serde::Serialize)]
163158
struct TestSuite<'a> {
164-
name: String,
165159
group: TestGroup<'a>,
166160
}
167161

168-
#[derive(Debug, serde::Serialize)]
169162
struct TestResults<'a> {
170163
passed: Vec<TestMetadata<'a>>,
171164
ignored: Vec<TestMetadata<'a>>,
172165
}
173166

174-
#[derive(Debug, serde::Serialize)]
175167
struct Test<'a> {
176-
name: String,
177168
revisions: BTreeMap<String, TestResults<'a>>,
178169
}
179170

@@ -189,7 +180,8 @@ impl<'a> Test<'a> {
189180
}
190181
}
191182

192-
#[derive(Clone, Copy, Debug, serde::Serialize)]
183+
#[derive(Clone, Copy)]
184+
#[allow(dead_code)]
193185
struct TestMetadata<'a> {
194186
job: &'a str,
195187
stage: u32,
@@ -198,13 +190,13 @@ struct TestMetadata<'a> {
198190

199191
// We have to use a template for the TestGroup instead of a macro, because
200192
// macros cannot be recursive in askama at the moment.
201-
#[derive(Template, serde::Serialize)]
193+
#[derive(Template)]
202194
#[template(path = "test_group.askama")]
203195
/// Represents a group of tests
204196
struct TestGroup<'a> {
205197
name: String,
206198
/// Tests located directly in this directory
207-
root_tests: Vec<Test<'a>>,
199+
root_tests: Vec<(String, Test<'a>)>,
208200
/// Nested directories with additional tests
209201
groups: Vec<(String, TestGroup<'a>)>,
210202
}

src/ci/citool/templates/test_group.askama

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ passed: {{ r.passed.len() }}, ignored: {{ r.ignored.len() }}
2121

2222
{% if !root_tests.is_empty() %}
2323
<ul>
24-
{% for test in root_tests %}
24+
{% for (name, test) in root_tests %}
2525
<li>
2626
{% if let Some(result) = test.single_test() %}
27-
<b>{{ test.name }}</b> ({% call test_result(result) %})
27+
<b>{{ name }}</b> ({% call test_result(result) %})
2828
{% else %}
29-
<b>{{ test.name }}</b> ({{ test.revisions.len() }} revision{{ test.revisions.len() | pluralize }})
29+
<b>{{ name }}</b> ({{ test.revisions.len() }} revision{{ test.revisions.len() | pluralize }})
3030
<ul>
3131
{% for (revision, result) in test.revisions %}
3232
<li>#<i>{{ revision }}</i> ({% call test_result(result) %})</li>

0 commit comments

Comments
 (0)