Skip to content

Commit 73b2d59

Browse files
xtask: Return an error if formatting errors occur
1 parent c995e08 commit 73b2d59

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

xtask/src/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ fn run_host_tests(test_opt: &TestOpt) -> Result<()> {
231231

232232
/// Formats the project: nix, rust, and yml.
233233
fn run_fmt_project(fmt_opt: &FmtOpt) -> Result<()> {
234+
let mut any_errors = false;
235+
234236
// fmt rust
235237
{
236238
eprintln!("Formatting: rust");
@@ -255,6 +257,7 @@ fn run_fmt_project(fmt_opt: &FmtOpt) -> Result<()> {
255257
} else {
256258
eprintln!("❌ rust formatter failed: {e:#?}");
257259
}
260+
any_errors = true;
258261
}
259262
}
260263
}
@@ -279,6 +282,7 @@ fn run_fmt_project(fmt_opt: &FmtOpt) -> Result<()> {
279282
} else {
280283
eprintln!("❌ yml formatter failed: {e:#?}");
281284
}
285+
any_errors = true;
282286
}
283287
}
284288
} else {
@@ -305,12 +309,17 @@ fn run_fmt_project(fmt_opt: &FmtOpt) -> Result<()> {
305309
} else {
306310
eprintln!("❌ nix formatter failed: {e:#?}");
307311
}
312+
any_errors = true;
308313
}
309314
}
310315
} else {
311316
eprintln!("Formatting: nix - SKIPPED");
312317
}
313318

319+
if any_errors {
320+
bail!("one or more formatting errors");
321+
}
322+
314323
Ok(())
315324
}
316325

0 commit comments

Comments
 (0)