Skip to content

Commit 2840b2c

Browse files
committed
test: fix clippy warnings in e2e-cucumber and exclude from workspace test hook
Signed-off-by: fredespi <fredrik.espinoza@gmail.com>
1 parent ffab5e2 commit 2840b2c

3 files changed

Lines changed: 22 additions & 22 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ repos:
116116
groups: [local-tools] # runs in the dedicated `clippy` CI job
117117
- id: cargo-test
118118
name: cargo test
119-
entry: cargo test --workspace --all-targets
119+
entry: cargo test --workspace --all-targets --exclude e2e-cucumber
120120
language: system
121121
types: [rust]
122122
pass_filenames: false

tests/e2e-cucumber/src/mock_server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl std::fmt::Debug for MockServer {
2828
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2929
f.debug_struct("MockServer")
3030
.field("addr", &self.addr)
31-
.finish()
31+
.finish_non_exhaustive()
3232
}
3333
}
3434

@@ -71,7 +71,7 @@ impl MockServer {
7171
format!("http://{}/v1", self.addr)
7272
}
7373

74-
pub fn port(&self) -> u16 {
74+
pub const fn port(&self) -> u16 {
7575
self.addr.port()
7676
}
7777

tests/e2e-cucumber/src/report.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct Stats {
5858
}
5959

6060
impl Stats {
61-
fn new() -> Self {
61+
const fn new() -> Self {
6262
Self {
6363
total: 0,
6464
passed: 0,
@@ -99,7 +99,7 @@ impl Stats {
9999
)
100100
}
101101

102-
fn status_text(&self) -> &'static str {
102+
const fn status_text(&self) -> &'static str {
103103
if self.failed > 0 {
104104
"FAIL"
105105
} else if self.total == 0 {
@@ -110,7 +110,7 @@ impl Stats {
110110
}
111111
}
112112

113-
fn scenario_status(el: &Element) -> &str {
113+
fn scenario_status(el: &Element) -> &'static str {
114114
for s in &el.steps {
115115
if s.result.status == "failed" {
116116
return "failed";
@@ -159,7 +159,7 @@ pub fn generate(json_path: &Path, html_path: &Path) -> std::io::Result<()> {
159159
.map(|d| {
160160
let secs = d.as_secs();
161161
let days = secs / 86400;
162-
let y = 1970 + (days * 400 / 146097);
162+
let y = 1970 + (days * 400 / 146_097);
163163
format!("{y}-xx-xx (epoch {secs})")
164164
})
165165
.unwrap_or_default();
@@ -317,46 +317,46 @@ pub fn generate(json_path: &Path, html_path: &Path) -> std::io::Result<()> {
317317
"<details class=\"scenario\">\n<summary class=\"scenario-row\">\n"
318318
)
319319
.unwrap();
320-
write!(
320+
writeln!(
321321
html,
322-
" <span class=\"badge {badge_class}\">{badge_text}</span>\n"
322+
" <span class=\"badge {badge_class}\">{badge_text}</span>"
323323
)
324324
.unwrap();
325-
write!(
325+
writeln!(
326326
html,
327-
" <span class=\"scenario-name\">{}</span>\n",
327+
" <span class=\"scenario-name\">{}</span>",
328328
escape(&scenario.name)
329329
)
330330
.unwrap();
331331
for tag in &scenario.tags {
332-
write!(html, " <span class=\"tag\">{}</span>\n", escape(&tag.name)).unwrap();
332+
writeln!(html, " <span class=\"tag\">{}</span>", escape(&tag.name)).unwrap();
333333
}
334-
write!(html, " <span class=\"elapsed\">{dur_ms}ms</span>\n").unwrap();
335-
write!(html, "</summary>\n").unwrap();
334+
writeln!(html, " <span class=\"elapsed\">{dur_ms}ms</span>").unwrap();
335+
writeln!(html, "</summary>").unwrap();
336336

337-
write!(html, "<div class=\"steps\">\n").unwrap();
337+
writeln!(html, "<div class=\"steps\">").unwrap();
338338
for step in &scenario.steps {
339339
let (icon, icon_class) = match step.result.status.as_str() {
340340
"passed" => ("&#x2714;", "pass"),
341341
"failed" => ("&#x2718;", "fail"),
342342
_ => ("&#x25CB;", ""),
343343
};
344344
let step_ms = step.result.duration / 1_000_000;
345-
write!(
345+
writeln!(
346346
html,
347-
" <div class=\"step\"><span class=\"step-icon {icon_class}\">{icon}</span><span class=\"step-keyword\">{}</span>{}<span class=\"step-duration\">{step_ms}ms</span></div>\n",
347+
" <div class=\"step\"><span class=\"step-icon {icon_class}\">{icon}</span><span class=\"step-keyword\">{}</span>{}<span class=\"step-duration\">{step_ms}ms</span></div>",
348348
escape(&step.keyword),
349349
escape(&step.name),
350350
).unwrap();
351351

352352
if let Some(err) = &step.result.error_message {
353-
write!(html, " <div class=\"error-box\">{}</div>\n", escape(err)).unwrap();
353+
writeln!(html, " <div class=\"error-box\">{}</div>", escape(err)).unwrap();
354354
}
355355
}
356356
write!(html, "</div>\n</details>\n").unwrap();
357357
}
358358

359-
write!(html, "</div>\n").unwrap();
359+
writeln!(html, "</div>").unwrap();
360360
}
361361

362362
write!(html, "</div>\n</body>\n</html>\n").unwrap();
@@ -373,10 +373,10 @@ fn write_stats_table(html: &mut String, title: &str, rows: &[(String, &Stats)])
373373
)
374374
.unwrap();
375375
for (label, stats) in rows {
376-
write!(
376+
writeln!(
377377
html,
378378
"<tr><td><a href=\"#\">{}</a></td><td class=\"num\">{}</td><td class=\"num\">{}</td>\
379-
<td class=\"num\">{}</td><td class=\"num\">{}</td><td class=\"num\">{}</td><td>{}</td></tr>\n",
379+
<td class=\"num\">{}</td><td class=\"num\">{}</td><td class=\"num\">{}</td><td>{}</td></tr>",
380380
escape(label),
381381
stats.total,
382382
stats.passed,
@@ -386,7 +386,7 @@ fn write_stats_table(html: &mut String, title: &str, rows: &[(String, &Stats)])
386386
stats.bar_html(),
387387
).unwrap();
388388
}
389-
write!(html, "</table>\n").unwrap();
389+
writeln!(html, "</table>").unwrap();
390390
}
391391

392392
fn escape(s: &str) -> String {

0 commit comments

Comments
 (0)