@@ -7,8 +7,7 @@ use async_trait::async_trait;
77use cubestore:: sql:: { QueryPlans , SqlQueryContext , SqlService } ;
88use cubestore:: store:: DataFrame ;
99use cubestore:: CubeError ;
10- use itertools:: Itertools ;
11- use std:: env;
10+ use std:: env:: args;
1211use std:: panic:: RefUnwindSafe ;
1312use std:: sync:: Arc ;
1413use test:: TestFn :: DynTestFn ;
@@ -66,14 +65,19 @@ pub fn run_sql_tests(
6665 } )
6766 . collect ( ) ;
6867
69- test:: test_main (
70- & env:: args ( )
71- . chain ( extra_args)
72- . unique ( )
73- . collect :: < Vec < String > > ( ) ,
74- tests,
75- None ,
76- ) ;
68+ test:: test_main ( & merge_args ( args ( ) . collect ( ) , extra_args) , tests, None ) ;
69+ }
70+
71+ fn merge_args ( mut base : Vec < String > , extra : Vec < String > ) -> Vec < String > {
72+ for extra_arg in extra. into_iter ( ) {
73+ if let Some ( ( arg_name, _arg_value) ) = extra_arg. split_once ( '=' ) {
74+ base. retain ( |a| !a. starts_with ( arg_name) ) ;
75+ }
76+
77+ base. push ( extra_arg. to_string ( ) ) ;
78+ }
79+
80+ base
7781}
7882
7983#[ async_trait]
@@ -94,3 +98,30 @@ impl SqlClient for Arc<dyn SqlService> {
9498 self . as_ref ( ) . plan_query ( query) . await
9599 }
96100}
101+
102+ #[ cfg( test) ]
103+ mod test_helpers {
104+ use super :: * ;
105+
106+ #[ test]
107+ fn test_merge_args ( ) {
108+ let base = vec ! [
109+ "path/to/executable" . to_string( ) ,
110+ "--test-threads=1" . to_string( ) ,
111+ ] ;
112+ let extra = vec ! [
113+ "--test-threads=2" . to_string( ) ,
114+ "--skip=planning_inplace_aggregate2" . to_string( ) ,
115+ ] ;
116+
117+ let merged = merge_args ( base, extra) ;
118+ assert_eq ! (
119+ merged,
120+ vec![
121+ "path/to/executable" ,
122+ "--test-threads=2" ,
123+ "--skip=planning_inplace_aggregate2"
124+ ]
125+ ) ;
126+ }
127+ }
0 commit comments