File tree Expand file tree Collapse file tree 2 files changed +26
-7
lines changed
site/src/request_handlers Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -406,6 +406,10 @@ impl CodegenBackend {
406406 CodegenBackend :: Cranelift => "cranelift" ,
407407 }
408408 }
409+
410+ pub fn all_values ( ) -> & ' static [ Self ] {
411+ & [ Self :: Llvm , Self :: Cranelift ]
412+ }
409413}
410414
411415impl FromStr for CodegenBackend {
@@ -1009,12 +1013,7 @@ impl BenchmarkRequest {
10091013 return Ok ( vec ! [ CodegenBackend :: Llvm ] ) ;
10101014 }
10111015
1012- self . backends
1013- . split ( ',' )
1014- . map ( |s| {
1015- CodegenBackend :: from_str ( s) . map_err ( |_| anyhow:: anyhow!( "Invalid backend: {s}" ) )
1016- } )
1017- . collect ( )
1016+ parse_backends ( & self . backends ) . map_err ( |e| anyhow:: anyhow!( "{e}" ) )
10181017 }
10191018
10201019 /// Get the profiles for the request
@@ -1040,6 +1039,13 @@ impl BenchmarkRequest {
10401039 }
10411040}
10421041
1042+ pub fn parse_backends ( backends : & str ) -> Result < Vec < CodegenBackend > , String > {
1043+ backends
1044+ . split ( ',' )
1045+ . map ( |s| CodegenBackend :: from_str ( s) . map_err ( |_| format ! ( "Invalid backend: {s}" ) ) )
1046+ . collect ( )
1047+ }
1048+
10431049/// Cached information about benchmark requests in the DB
10441050pub struct BenchmarkRequestIndex {
10451051 /// Tags (SHA or release name) of all known benchmark requests
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ use crate::github::{
66use crate :: job_queue:: should_use_job_queue;
77use crate :: load:: SiteCtxt ;
88
9- use database:: BenchmarkRequest ;
9+ use database:: { parse_backends , BenchmarkRequest , CodegenBackend } ;
1010use hashbrown:: HashMap ;
1111use std:: sync:: Arc ;
1212
@@ -265,6 +265,19 @@ fn parse_benchmark_parameters<'a>(
265265 } ;
266266 params. runs = Some ( runs as i32 ) ;
267267 }
268+ if let Some ( backends) = & params. backends {
269+ // Make sure that the backends are correct
270+ parse_backends ( backends) . map_err ( |e| {
271+ format ! (
272+ "Cannot parse backends: {e}. Valid values are: {}" ,
273+ CodegenBackend :: all_values( )
274+ . iter( )
275+ . map( |b| b. as_str( ) )
276+ . collect:: <Vec <_>>( )
277+ . join( ", " )
278+ )
279+ } ) ?;
280+ }
268281
269282 if !args. is_empty ( ) {
270283 Err ( format ! (
You can’t perform that action at this time.
0 commit comments