@@ -64,6 +64,10 @@ pub struct Diffing {
64
64
#[ clap( long, short = 'P' ) ]
65
65
pub use_pager_directly : bool ,
66
66
67
+ /// URL for SVD to download
68
+ #[ clap( global = true , long) ]
69
+ pub url : Option < String > ,
70
+
67
71
#[ clap( last = true ) ]
68
72
pub last_args : Option < String > ,
69
73
}
@@ -176,12 +180,32 @@ impl Diffing {
176
180
}
177
181
} )
178
182
. collect :: < Vec < _ > > ( ) ;
179
- let test = match ( tests. len ( ) , self . sub . as_ref ( ) ) {
180
- ( 1 , _) => tests[ 0 ] ,
181
- ( _, Some ( DiffingMode :: Pr { .. } ) ) => tests
183
+
184
+ let test = match ( tests. len ( ) , self . sub . as_ref ( ) , self . url . as_ref ( ) ) {
185
+ ( 1 , _, None ) => tests[ 0 ] . clone ( ) ,
186
+ ( _, Some ( DiffingMode :: Pr { .. } ) , None ) => tests
182
187
. iter ( )
183
188
. find ( |t| t. chip == "STM32F103" )
184
- . unwrap_or ( & tests[ 0 ] ) ,
189
+ . map ( |t| ( * t) . clone ( ) )
190
+ . unwrap_or_else ( || tests[ 0 ] . clone ( ) ) ,
191
+ ( _, _, Some ( url) ) => crate :: tests:: TestCase {
192
+ arch : self
193
+ . arch
194
+ . clone ( )
195
+ . map ( |s| svd2rust:: Target :: parse ( & s) )
196
+ . transpose ( ) ?
197
+ . unwrap_or_default ( ) ,
198
+ mfgr : crate :: tests:: Manufacturer :: Unknown ,
199
+ chip : url
200
+ . rsplit ( '/' )
201
+ . next ( )
202
+ . and_then ( |file| file. split ( '.' ) . next ( ) )
203
+ . ok_or_else ( || anyhow:: anyhow!( "couldn't get chip name from url" ) ) ?
204
+ . to_owned ( ) ,
205
+ svd_url : Some ( url. to_owned ( ) ) ,
206
+ should_pass : true ,
207
+ run_when : crate :: tests:: RunWhen :: Always ,
208
+ } ,
185
209
_ => {
186
210
let error = anyhow:: anyhow!( "diff requires exactly one test case" ) ;
187
211
let len = tests. len ( ) ;
0 commit comments