@@ -21,18 +21,28 @@ use verify::{method, model, ssot, Version};
2121// TODO: Add a --quiet option.
2222
2323const VERSIONS : [ Version ; 13 ] = [
24- Version :: V17 , Version :: V18 , Version :: V19 , Version :: V20 , Version :: V21 , Version :: V22 ,
25- Version :: V23 , Version :: V24 , Version :: V25 , Version :: V26 , Version :: V27 , Version :: V28 ,
24+ Version :: V17 ,
25+ Version :: V18 ,
26+ Version :: V19 ,
27+ Version :: V20 ,
28+ Version :: V21 ,
29+ Version :: V22 ,
30+ Version :: V23 ,
31+ Version :: V24 ,
32+ Version :: V25 ,
33+ Version :: V26 ,
34+ Version :: V27 ,
35+ Version :: V28 ,
2636 Version :: V29 ,
2737] ;
2838
2939fn main ( ) -> Result < ( ) > {
30- let cmd = Command :: new ( "verify" )
31- . args ( [
32- arg ! ( [ version ] "Verify specific version of Core (use \" all \" for all versions)" ) . required ( true ) ,
33- arg ! ( -t --tests <TEST_OUTPUT > "Optionally check claimed status of tests" ) . required ( false ) ,
34- arg ! ( -q --quiet ... "Run tests in quiet mode" ) . required ( false ) ,
35- ] ) ;
40+ let cmd = Command :: new ( "verify" ) . args ( [
41+ arg ! ( [ version ] "Verify specific version of Core (use \" all \" for all versions)" )
42+ . required ( true ) ,
43+ arg ! ( -t --tests <TEST_OUTPUT > "Optionally check claimed status of tests" ) . required ( false ) ,
44+ arg ! ( -q --quiet ... "Run tests in quiet mode" ) . required ( false ) ,
45+ ] ) ;
3646
3747 let matches = cmd. clone ( ) . get_matches ( ) ;
3848 let version = matches. get_one :: < String > ( "version" ) . unwrap ( ) ;
@@ -61,7 +71,7 @@ fn verify_all_versions(test_output: Option<&String>, quiet: bool) -> Result<()>
6171 }
6272 }
6373 if any_failed {
64- return Err ( anyhow:: anyhow!( "verification failed for one or more versions" ) )
74+ return Err ( anyhow:: anyhow!( "verification failed for one or more versions" ) ) ;
6575 }
6676 Ok ( ( ) )
6777}
@@ -74,29 +84,53 @@ fn verify_version(version: Version, test_output: Option<&String>, quiet: bool) -
7484 check ( & msg, quiet) ;
7585 match verify_correct_methods ( version, method:: all_methods ( version) , & s) {
7686 Ok ( ( ) ) => close ( true , quiet) ,
77- Err ( e) => { if !quiet { eprintln ! ( "{}" , e) ; } close ( false , quiet) ; failures += 1 ; }
87+ Err ( e) => {
88+ if !quiet {
89+ eprintln ! ( "{}" , e) ;
90+ }
91+ close ( false , quiet) ;
92+ failures += 1 ;
93+ }
7894 }
7995
8096 let s = "rustdoc version specific rustdocs" ;
8197 let msg = format ! ( "Checking that the {} list is correct" , s) ;
8298 check ( & msg, quiet) ;
8399 match verify_correct_methods ( version, versioned:: all_methods ( version) ?, s) {
84100 Ok ( ( ) ) => close ( true , quiet) ,
85- Err ( e) => { if !quiet { eprintln ! ( "{}" , e) ; } close ( false , quiet) ; failures += 1 ; }
101+ Err ( e) => {
102+ if !quiet {
103+ eprintln ! ( "{}" , e) ;
104+ }
105+ close ( false , quiet) ;
106+ failures += 1 ;
107+ }
86108 }
87109
88110 let msg = "Checking that the status claimed in the version specific rustdocs is correct" ;
89111 check ( msg, quiet) ;
90112 match verify_status ( version, test_output) {
91113 Ok ( ( ) ) => close ( true , quiet) ,
92- Err ( e) => { if !quiet { eprintln ! ( "{}" , e) ; } close ( false , quiet) ; failures += 1 ; }
114+ Err ( e) => {
115+ if !quiet {
116+ eprintln ! ( "{}" , e) ;
117+ }
118+ close ( false , quiet) ;
119+ failures += 1 ;
120+ }
93121 }
94122
95123 let msg = "Checking that 'Returns' column matches model requirements" ;
96124 check ( msg, quiet) ;
97125 match verify_returns_method ( version) {
98126 Ok ( ( ) ) => close ( true , quiet) ,
99- Err ( e) => { if !quiet { eprintln ! ( "{}" , e) ; } close ( false , quiet) ; failures += 1 ; }
127+ Err ( e) => {
128+ if !quiet {
129+ eprintln ! ( "{}" , e) ;
130+ }
131+ close ( false , quiet) ;
132+ failures += 1 ;
133+ }
100134 }
101135
102136 if failures > 0 {
@@ -112,11 +146,13 @@ fn check(msg: &str, quiet: bool) {
112146}
113147
114148fn close ( correct : bool , quiet : bool ) {
115- if quiet { return ; }
149+ if quiet {
150+ return ;
151+ }
116152 if correct {
117153 println ! ( "Correct \u{2713} \n " ) ;
118154 } else {
119- println ! ( "\u{001b} [31mIncorrect \u{2717} \u{001b} [0m \n " ) ;
155+ println ! ( "\u{001b} [31mIncorrect \u{2717} \u{001b} [0m \n " ) ;
120156 }
121157}
122158
@@ -143,7 +179,9 @@ fn verify_status(version: Version, test_output: Option<&String>) -> Result<()> {
143179 }
144180
145181 if let Some ( test_output) = test_output {
146- if check_integration_test_crate:: test_exists ( version, & method. name , test_output) . is_err ( ) {
182+ if check_integration_test_crate:: test_exists ( version, & method. name , test_output)
183+ . is_err ( )
184+ {
147185 eprintln ! ( "missing integration test: {}" , method. name) ;
148186 failures += 1 ;
149187 }
@@ -156,23 +194,35 @@ fn verify_status(version: Version, test_output: Option<&String>) -> Result<()> {
156194
157195 // Make sure we didn't forget to mark as tested after implementing integration test.
158196 if let Some ( test_output) = test_output {
159- if check_integration_test_crate:: test_exists ( version, & method. name , test_output) . is_ok ( ) {
197+ if check_integration_test_crate:: test_exists ( version, & method. name , test_output)
198+ . is_ok ( )
199+ {
160200 eprintln ! ( "found integration test for untested method: {}" , method. name) ;
161201 failures += 1 ;
162202 }
163203 }
164204 }
165205 Status :: Omitted | Status :: Todo => {
166- let out =
167- Method :: from_name ( version , & method . name ) . expect ( "guaranteed by methods_and_status()" ) ;
206+ let out = Method :: from_name ( version , & method . name )
207+ . expect ( "guaranteed by methods_and_status()" ) ;
168208
169- if versioned:: type_exists ( version, & method. name ) ? && !versioned:: requires_type ( version, & method. name ) ? {
170- eprintln ! ( "return type found but method is omitted or TODO: {}" , output_method( out) ) ;
209+ if versioned:: type_exists ( version, & method. name ) ?
210+ && !versioned:: requires_type ( version, & method. name ) ?
211+ {
212+ eprintln ! (
213+ "return type found but method is omitted or TODO: {}" ,
214+ output_method( out)
215+ ) ;
171216 failures += 1 ;
172217 }
173218
174- if model:: type_exists ( version, & method. name ) ? && !model:: requires_type ( version, & method. name ) ? {
175- eprintln ! ( "model type found but method is omitted or TODO: {}" , output_method( out) ) ;
219+ if model:: type_exists ( version, & method. name ) ?
220+ && !model:: requires_type ( version, & method. name ) ?
221+ {
222+ eprintln ! (
223+ "model type found but method is omitted or TODO: {}" ,
224+ output_method( out)
225+ ) ;
176226 failures += 1 ;
177227 }
178228 }
@@ -188,7 +238,9 @@ fn verify_status(version: Version, test_output: Option<&String>) -> Result<()> {
188238fn check_types_exist_if_required ( version : Version , method_name : & str ) -> Result < ( ) > {
189239 let out = Method :: from_name ( version, method_name) . expect ( "guaranteed by methods_and_status()" ) ;
190240
191- if versioned:: requires_type ( version, method_name) ? && !versioned:: type_exists ( version, method_name) ? {
241+ if versioned:: requires_type ( version, method_name) ?
242+ && !versioned:: type_exists ( version, method_name) ?
243+ {
192244 eprintln ! ( "missing return type: {}" , output_method( out) ) ;
193245 return Err ( anyhow:: anyhow!( "missing return type" ) ) ;
194246 }
@@ -223,29 +275,29 @@ fn verify_returns_method(version: Version) -> Result<()> {
223275 let Some ( method) = Method :: from_name ( version, & name) else { continue } ;
224276
225277 match entry {
226- ReturnsDoc :: Version => {
278+ ReturnsDoc :: Version =>
227279 if method. requires_model {
228280 eprintln ! (
229281 "'Returns' says 'version' but method is marked as requiring a model: {}" ,
230282 output_method( method)
231283 ) ;
232284 failures += 1 ;
233- }
234- }
235- ReturnsDoc :: VersionPlusModel => {
285+ } ,
286+ ReturnsDoc :: VersionPlusModel =>
236287 if !method. requires_model {
237288 eprintln ! (
238289 "'Returns' says 'version + model' but method is marked as not requiring a model: {}" ,
239290 output_method( method)
240291 ) ;
241292 failures += 1 ;
242- }
243- }
293+ } ,
244294 ReturnsDoc :: Other ( _) => { }
245295 }
246296 }
247297
248- if failures > 0 { return Err ( anyhow:: anyhow!( "returns/model verification failed ({} issue(s))" , failures) ) ; }
298+ if failures > 0 {
299+ return Err ( anyhow:: anyhow!( "returns/model verification failed ({} issue(s))" , failures) ) ;
300+ }
249301
250302 Ok ( ( ) )
251303}
@@ -268,9 +320,8 @@ mod check_integration_test_crate {
268320 let mut functions = vec ! [ ] ;
269321
270322 let path = PathBuf :: from ( test_output) ;
271- let file = File :: open ( & path) . with_context ( || {
272- format ! ( "Failed to open test output file {}" , path. display( ) )
273- } ) ?;
323+ let file = File :: open ( & path)
324+ . with_context ( || format ! ( "Failed to open test output file {}" , path. display( ) ) ) ?;
274325 let reader = io:: BufReader :: new ( file) ;
275326 let test_re = Regex :: new ( r"test ([a-z_]+) ... ok" ) ?;
276327
@@ -304,7 +355,7 @@ mod check_integration_test_crate {
304355 } ;
305356 for t in all_test_functions ( test_output) ? {
306357 if t. contains ( & test_name) {
307- return Ok ( true )
358+ return Ok ( true ) ;
308359 }
309360 }
310361 Ok ( false )
0 commit comments