@@ -64,6 +64,10 @@ pub struct Diffing {
6464 #[ clap( long, short = 'P' ) ]
6565 pub use_pager_directly : bool ,
6666
67+ /// URL for SVD to download
68+ #[ clap( global = true , long) ]
69+ pub url : Option < String > ,
70+
6771 #[ clap( last = true ) ]
6872 pub last_args : Option < String > ,
6973}
@@ -176,12 +180,32 @@ impl Diffing {
176180 }
177181 } )
178182 . 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
182187 . iter ( )
183188 . 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+ } ,
185209 _ => {
186210 let error = anyhow:: anyhow!( "diff requires exactly one test case" ) ;
187211 let len = tests. len ( ) ;
0 commit comments