@@ -64,6 +64,12 @@ enum LintType {
64
64
Warning ,
65
65
}
66
66
67
+ #[ derive( Debug , Copy , Clone ) ]
68
+ pub ( crate ) enum WarningDisposition {
69
+ AllowWarnings ,
70
+ FatalWarnings ,
71
+ }
72
+
67
73
#[ derive( Debug , Serialize ) ]
68
74
#[ serde( rename_all = "kebab-case" ) ]
69
75
struct Lint {
@@ -163,7 +169,7 @@ pub(crate) fn lint_list(output: impl std::io::Write) -> Result<()> {
163
169
#[ context( "Linting" ) ]
164
170
pub ( crate ) fn lint (
165
171
root : & Dir ,
166
- fatal_warnings : bool ,
172
+ warning_disposition : WarningDisposition ,
167
173
mut output : impl std:: io:: Write ,
168
174
) -> Result < ( ) > {
169
175
let mut fatal = 0usize ;
@@ -194,7 +200,7 @@ pub(crate) fn lint(
194
200
}
195
201
}
196
202
writeln ! ( output, "Checks passed: {passed}" ) ?;
197
- let fatal = if fatal_warnings {
203
+ let fatal = if matches ! ( warning_disposition , WarningDisposition :: FatalWarnings ) {
198
204
fatal + warnings
199
205
} else {
200
206
fatal
@@ -424,10 +430,11 @@ mod tests {
424
430
fn test_lint_main ( ) -> Result < ( ) > {
425
431
let root = & passing_fixture ( ) ?;
426
432
let mut out = Vec :: new ( ) ;
427
- lint ( root, true , & mut out) . unwrap ( ) ;
433
+ let warnings = WarningDisposition :: FatalWarnings ;
434
+ lint ( root, warnings, & mut out) . unwrap ( ) ;
428
435
root. create_dir_all ( "var/run/foo" ) ?;
429
436
let mut out = Vec :: new ( ) ;
430
- assert ! ( lint( root, true , & mut out) . is_err( ) ) ;
437
+ assert ! ( lint( root, warnings , & mut out) . is_err( ) ) ;
431
438
Ok ( ( ) )
432
439
}
433
440
0 commit comments