Prepare the benchmark command wrapped with the necessary environment variables for introspection and environment forwarding ahead of privilege escalation and isolation.
(
config: &ExecutorConfig,
execution_context: &ExecutionContext,
)
| 64 | /// Prepare the benchmark command wrapped with the necessary environment variables for |
| 65 | /// introspection and environment forwarding ahead of privilege escalation and isolation. |
| 66 | fn walltime_bench_cmd( |
| 67 | config: &ExecutorConfig, |
| 68 | execution_context: &ExecutionContext, |
| 69 | ) -> Result<(NamedTempFile, NamedTempFile, CommandBuilder)> { |
| 70 | let path_value = build_path_env(config.enable_introspection)?; |
| 71 | |
| 72 | let mut extra_env = get_base_injected_env( |
| 73 | RunnerMode::Walltime, |
| 74 | &execution_context.profile_folder, |
| 75 | &execution_context.config, |
| 76 | ); |
| 77 | extra_env.insert("PATH".into(), path_value); |
| 78 | |
| 79 | // We have to write the benchmark command to a script, to ensure proper formatting |
| 80 | // and to not have to manually escape everything. |
| 81 | let mut script_file = NamedTempFile::new()?; |
| 82 | script_file.write_all(get_bench_command(config)?.as_bytes())?; |
| 83 | |
| 84 | let mut bench_cmd = CommandBuilder::new("bash"); |
| 85 | bench_cmd.arg(script_file.path()); |
| 86 | let (mut bench_cmd, env_file) = wrap_with_env(bench_cmd, &extra_env)?; |
| 87 | |
| 88 | if let Some(cwd) = &config.working_directory { |
| 89 | let abs_cwd = canonicalize(cwd)?; |
| 90 | bench_cmd.current_dir(abs_cwd); |
| 91 | } |
| 92 | |
| 93 | Ok((env_file, script_file, bench_cmd)) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | #[async_trait(?Send)] |
nothing calls this directly
no test coverage detected