( executor: CommandExecutor, fileSystemExecutor: FileSystemExecutor = getDefaultFileSystemExecutor(), prepared?: PreparedTestSimExecution, )
| 188 | } |
| 189 | |
| 190 | export function createTestSimExecutor( |
| 191 | executor: CommandExecutor, |
| 192 | fileSystemExecutor: FileSystemExecutor = getDefaultFileSystemExecutor(), |
| 193 | prepared?: PreparedTestSimExecution, |
| 194 | ): StreamingExecutor<TestSimulatorParams, TestSimulatorResult> { |
| 195 | return async (params, ctx) => { |
| 196 | const resolved = |
| 197 | prepared ?? (await prepareTestSimExecution(params, executor, fileSystemExecutor)); |
| 198 | |
| 199 | if (resolved.warningMessage) { |
| 200 | log('warn', resolved.warningMessage); |
| 201 | ctx.emitFragment({ |
| 202 | kind: 'test-result', |
| 203 | fragment: 'warning', |
| 204 | message: resolved.warningMessage, |
| 205 | }); |
| 206 | } |
| 207 | |
| 208 | if (resolved.resolutionError || !resolved.resolvedSimulatorId) { |
| 209 | const started = createDomainStreamingPipeline('test_sim', 'TEST', ctx, 'test-result'); |
| 210 | return createTestDomainResult({ |
| 211 | started, |
| 212 | succeeded: false, |
| 213 | target: 'simulator', |
| 214 | artifacts: { |
| 215 | buildLogPath: started.pipeline.logPath, |
| 216 | }, |
| 217 | fallbackErrorMessages: [ |
| 218 | resolved.resolutionError ?? 'Failed to resolve simulator identifier for test execution.', |
| 219 | ], |
| 220 | request: resolved.invocationRequest, |
| 221 | }); |
| 222 | } |
| 223 | |
| 224 | const executeTest = createTestExecutor(executor, { |
| 225 | preflight: resolved.preflight, |
| 226 | toolName: 'test_sim', |
| 227 | target: 'simulator', |
| 228 | request: resolved.invocationRequest, |
| 229 | }); |
| 230 | |
| 231 | return executeTest( |
| 232 | { |
| 233 | projectPath: params.projectPath, |
| 234 | workspacePath: params.workspacePath, |
| 235 | scheme: params.scheme, |
| 236 | simulatorId: resolved.resolvedSimulatorId, |
| 237 | simulatorName: params.simulatorName, |
| 238 | configuration: resolved.configuration, |
| 239 | derivedDataPath: params.derivedDataPath, |
| 240 | extraArgs: params.extraArgs, |
| 241 | useLatestOS: false, |
| 242 | preferXcodebuild: params.preferXcodebuild ?? false, |
| 243 | platform: resolved.platform, |
| 244 | testRunnerEnv: params.testRunnerEnv, |
| 245 | progress: params.progress, |
| 246 | }, |
| 247 | ctx, |
no test coverage detected