(
&mut self,
execution_context: &ExecutionContext,
_mongo_tracer: &Option<MongoTracer>,
)
| 172 | } |
| 173 | |
| 174 | async fn run( |
| 175 | &mut self, |
| 176 | execution_context: &ExecutionContext, |
| 177 | _mongo_tracer: &Option<MongoTracer>, |
| 178 | ) -> Result<()> { |
| 179 | let _guard = HookScriptsGuard::setup(); |
| 180 | |
| 181 | let (_env_file, _script_file, cmd_builder) = |
| 182 | WallTimeExecutor::walltime_bench_cmd(&execution_context.config, execution_context)?; |
| 183 | |
| 184 | // Resolve the isolation decision once and reuse it for both the scope |
| 185 | // wrapping here and the privilege wrapping below (or in the profiler). |
| 186 | let isolate = requires_isolation(); |
| 187 | let cmd_builder = if isolate { |
| 188 | wrap_isolation_scope(cmd_builder)? |
| 189 | } else { |
| 190 | cmd_builder |
| 191 | }; |
| 192 | |
| 193 | // Split-borrow `self` so the closure inside `run_with_profiler` can |
| 194 | // capture `benchmark_state` while we hold `&mut profiler`. |
| 195 | let Self { |
| 196 | profiler, |
| 197 | benchmark_state, |
| 198 | } = self; |
| 199 | |
| 200 | let status = match profiler.as_mut() { |
| 201 | Some(profiler) if execution_context.config.enable_profiler => { |
| 202 | run_with_profiler( |
| 203 | profiler.as_mut(), |
| 204 | cmd_builder, |
| 205 | &execution_context.config, |
| 206 | &execution_context.profile_folder, |
| 207 | isolate, |
| 208 | benchmark_state, |
| 209 | ) |
| 210 | .await |
| 211 | } |
| 212 | _ => { |
| 213 | // No profiler: still honor the isolation decision, since the |
| 214 | // scope (and the sudo it requires) is a property of the run, not |
| 215 | // of the profiler. |
| 216 | let cmd_builder = if isolate { |
| 217 | wrap_with_sudo(cmd_builder)? |
| 218 | } else { |
| 219 | cmd_builder |
| 220 | }; |
| 221 | let cmd = cmd_builder.build(); |
| 222 | debug!("cmd: {cmd:?}"); |
| 223 | run_command_with_log_pipe(cmd).await |
| 224 | } |
| 225 | }; |
| 226 | |
| 227 | let status = status.map_err(|e| anyhow!("failed to execute the benchmark process. {e}"))?; |
| 228 | debug!("cmd exit status: {status:?}"); |
| 229 | |
| 230 | if !status.success() { |
| 231 | bail!("failed to execute the benchmark process: {status}"); |
nothing calls this directly
no test coverage detected