11use std:: {
22 borrow:: Cow ,
3- collections:: { BTreeMap , BTreeSet } ,
3+ collections:: { BTreeMap , BTreeSet , HashSet } ,
44 fmt:: Display ,
55 fs:: { File , OpenOptions } ,
66 ops:: { Deref , DerefMut } ,
@@ -9,11 +9,12 @@ use std::{
99} ;
1010
1111use anyhow:: { Context as _, Error , Result , bail} ;
12- use clap:: Parser ;
12+ use clap:: { Parser , ValueEnum } ;
1313use serde:: { Deserialize , Serialize , de:: DeserializeOwned } ;
1414
1515use revive_dt_common:: types:: { Mode , ParsedTestSpecifier } ;
1616use revive_dt_report:: { Report , TestCaseStatus } ;
17+ use strum:: EnumString ;
1718
1819fn main ( ) -> Result < ( ) > {
1920 let cli = Cli :: try_parse ( ) . context ( "Failed to parse the CLI arguments" ) ?;
@@ -23,11 +24,14 @@ fn main() -> Result<()> {
2324 report_path,
2425 output_path : output_file,
2526 remove_prefix,
27+ include_status,
2628 } => {
2729 let remove_prefix = remove_prefix
2830 . into_iter ( )
2931 . map ( |path| path. canonicalize ( ) . context ( "Failed to canonicalize path" ) )
3032 . collect :: < Result < Vec < _ > > > ( ) ?;
33+ let include_status =
34+ include_status. map ( |value| value. into_iter ( ) . collect :: < HashSet < _ > > ( ) ) ;
3135
3236 let expectations = report_path
3337 . execution_information
@@ -73,7 +77,12 @@ fn main() -> Result<()> {
7377 Status :: from ( status) ,
7478 )
7579 } )
76- . filter ( |( _, status) | * status == Status :: Failed )
80+ . filter ( |( _, status) | {
81+ include_status
82+ . as_ref ( )
83+ . map ( |allowed_status| allowed_status. contains ( status) )
84+ . unwrap_or ( true )
85+ } )
7786 . collect :: < Expectations > ( ) ;
7887
7988 let output_file = OpenOptions :: new ( )
@@ -143,6 +152,11 @@ pub enum Cli {
143152 /// Prefix paths to remove from the paths in the final expectations file.
144153 #[ clap( long) ]
145154 remove_prefix : Vec < PathBuf > ,
155+
156+ /// Controls which test case statuses are included in the generated expectations file. If
157+ /// nothing is specified then it will include all of the test case status.
158+ #[ clap( long) ]
159+ include_status : Option < Vec < Status > > ,
146160 } ,
147161
148162 /// Compares two expectation files to ensure that they match each other.
@@ -157,7 +171,21 @@ pub enum Cli {
157171 } ,
158172}
159173
160- #[ derive( Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord , Hash , Serialize , Deserialize ) ]
174+ #[ derive(
175+ Clone ,
176+ Copy ,
177+ Debug ,
178+ PartialEq ,
179+ Eq ,
180+ PartialOrd ,
181+ Ord ,
182+ Hash ,
183+ Serialize ,
184+ Deserialize ,
185+ ValueEnum ,
186+ EnumString ,
187+ ) ]
188+ #[ strum( serialize_all = "kebab-case" ) ]
161189pub enum Status {
162190 Succeeded ,
163191 Failed ,
0 commit comments