@@ -28,6 +28,15 @@ const BENCHMARK_COMMANDS: [&str; 5] = [
2828 DIRECTORY_CHECK_SCRIPT ,
2929] ;
3030
31+ const ENV_VAR_VALIDATION_SCRIPT : & str = "
32+ output=$(echo \" $MY_ENV_VAR\" )
33+ if [ \" $output\" != \" Hello\" ]; then
34+ echo \" Assertion failed: Expected 'Hello' but got '$output'\"
35+ exit 1
36+ fi" ;
37+
38+ const ENV_COMMANDS : [ ( & str , & str , & str ) ; 1 ] = [ ( "MY_ENV_VAR" , "Hello" , ENV_VAR_VALIDATION_SCRIPT ) ] ;
39+
3140async fn create_test_setup ( ) -> ( SystemInfo , RunData , TempDir ) {
3241 let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
3342
@@ -93,3 +102,55 @@ async fn test_walltime_executor() {
93102 }
94103 }
95104}
105+
106+ #[ tokio:: test]
107+ async fn test_valgrind_executor_with_env ( ) {
108+ let ( system_info, run_data, _temp_dir) = create_test_setup ( ) . await ;
109+
110+ let executor = ValgrindExecutor ;
111+ executor. setup ( & system_info) . await . unwrap ( ) ;
112+
113+ let config = Config {
114+ mode : RunnerMode :: Instrumentation ,
115+ ..Config :: test ( )
116+ } ;
117+ test_executor_with_env ( & executor, config, & system_info, & run_data) . await ;
118+ }
119+
120+ #[ tokio:: test]
121+ async fn test_walltime_executor_with_env ( ) {
122+ let ( system_info, run_data, _temp_dir) = create_test_setup ( ) . await ;
123+
124+ let executor = WallTimeExecutor :: new ( ) ;
125+ executor. setup ( & system_info) . await . unwrap ( ) ;
126+
127+ for enable_perf in [ false , true ] {
128+ let config = Config {
129+ mode : RunnerMode :: Walltime ,
130+ enable_perf,
131+ ..Config :: test ( )
132+ } ;
133+
134+ test_executor_with_env ( & executor, config, & system_info, & run_data) . await ;
135+ }
136+ }
137+
138+ async fn test_executor_with_env (
139+ executor : & dyn Executor ,
140+ mut config : Config ,
141+ system_info : & SystemInfo ,
142+ run_data : & RunData ,
143+ ) {
144+ for ( env_var, env_value, cmd) in ENV_COMMANDS {
145+ eprintln ! ( "Running command: {cmd}" ) ;
146+ config. command = cmd. to_string ( ) ;
147+
148+ temp_env:: async_with_vars ( & [ ( env_var, Some ( env_value) ) ] , async {
149+ executor
150+ . run ( & config, system_info, run_data, & None )
151+ . await
152+ . unwrap ( ) ;
153+ } )
154+ . await ;
155+ }
156+ }
0 commit comments