@@ -8,7 +8,7 @@ use std::path::Path;
88use std:: sync:: { Arc , Mutex } ;
99
1010// non-std crates
11- use anyhow:: Result ;
11+ use anyhow:: { anyhow , Result } ;
1212use log:: { set_max_level, LevelFilter } ;
1313#[ cfg( feature = "openssl-vendored" ) ]
1414use openssl_probe;
@@ -41,7 +41,7 @@ fn probe_ssl_certs() {
4141/// is used instead of python's `sys.argv`, then the list of strings includes the entry point
4242/// alias ("path/to/cpp-linter.exe"). Thus, the parser in [`crate::cli`] will halt on an error
4343/// because it is not configured to handle positional arguments.
44- pub async fn run_main ( args : Vec < String > ) -> Result < u8 > {
44+ pub async fn run_main ( args : Vec < String > ) -> Result < ( ) > {
4545 probe_ssl_certs ( ) ;
4646
4747 let arg_parser = get_arg_parser ( ) ;
@@ -50,15 +50,15 @@ pub async fn run_main(args: Vec<String>) -> Result<u8> {
5050
5151 if args. subcommand_matches ( "version" ) . is_some ( ) {
5252 println ! ( "cpp-linter v{}" , VERSION ) ;
53- return Ok ( 0 ) ;
53+ return Ok ( ( ) ) ;
5454 }
5555
5656 logger:: init ( ) . unwrap ( ) ;
5757
5858 if cli. version == "NO-VERSION" {
5959 log:: error!( "The `--version` arg is used to specify which version of clang to use." ) ;
6060 log:: error!( "To get the cpp-linter version, use `cpp-linter version` sub-command." ) ;
61- return Ok ( 1 ) ;
61+ return Err ( anyhow ! ( "Clang version not specified." ) ) ;
6262 }
6363
6464 if cli. repo_root != "." {
@@ -135,9 +135,13 @@ pub async fn run_main(args: Vec<String>) -> Result<u8> {
135135 . await ?;
136136 end_log_group ( ) ;
137137 if env:: var ( "PRE_COMMIT" ) . is_ok_and ( |v| v == "1" ) {
138- return Ok ( ( checks_failed > 1 ) as u8 ) ;
138+ if checks_failed > 1 {
139+ return Err ( anyhow ! ( "Some checks did not pass" ) ) ;
140+ } else {
141+ return Ok ( ( ) ) ;
142+ }
139143 }
140- Ok ( 0 )
144+ Ok ( ( ) )
141145}
142146
143147#[ cfg( test) ]
@@ -157,14 +161,14 @@ mod test {
157161 "demo/demo.cpp" . to_string( ) ,
158162 ] )
159163 . await ;
160- assert ! ( result. is_ok_and ( |v| v == 0 ) ) ;
164+ assert ! ( result. is_ok ( ) ) ;
161165 }
162166
163167 #[ tokio:: test]
164168 async fn version_command ( ) {
165169 env:: remove_var ( "GITHUB_OUTPUT" ) ; // avoid writing to GH_OUT in parallel-running tests
166170 let result = run_main ( vec ! [ "cpp-linter" . to_string( ) , "version" . to_string( ) ] ) . await ;
167- assert ! ( result. is_ok_and ( |v| v == 0 ) ) ;
171+ assert ! ( result. is_ok ( ) ) ;
168172 }
169173
170174 #[ tokio:: test]
@@ -178,7 +182,7 @@ mod test {
178182 "debug" . to_string( ) ,
179183 ] )
180184 . await ;
181- assert ! ( result. is_ok_and ( |v| v == 0 ) ) ;
185+ assert ! ( result. is_ok ( ) ) ;
182186 }
183187
184188 #[ tokio:: test]
@@ -191,7 +195,7 @@ mod test {
191195 "-V" . to_string( ) ,
192196 ] )
193197 . await ;
194- assert ! ( result. is_ok_and ( |v| v == 1 ) ) ;
198+ assert ! ( result. is_err ( ) ) ;
195199 }
196200
197201 #[ tokio:: test]
@@ -204,6 +208,6 @@ mod test {
204208 "false" . to_string( ) ,
205209 ] )
206210 . await ;
207- assert ! ( result. is_ok_and ( |v| v == 1 ) ) ;
211+ assert ! ( result. is_err ( ) ) ;
208212 }
209213}
0 commit comments