|
1 | 1 | import { describe, it, expect, beforeEach } from 'vitest'; |
2 | | -import { DERIVED_DATA_DIR } from '../../../../utils/log-paths.ts'; |
| 2 | +import { computeScopedDerivedDataPath } from '../../../../utils/derived-data-path.ts'; |
3 | 3 | import * as z from 'zod'; |
4 | 4 | import { |
5 | 5 | createMockCommandResponse, |
@@ -134,7 +134,7 @@ describe('get_device_app_path plugin', () => { |
134 | 134 | '-destination', |
135 | 135 | 'generic/platform=iOS', |
136 | 136 | '-derivedDataPath', |
137 | | - DERIVED_DATA_DIR, |
| 137 | + computeScopedDerivedDataPath('/path/to/project.xcodeproj'), |
138 | 138 | ], |
139 | 139 | logPrefix: 'Get App Path', |
140 | 140 | useShell: false, |
@@ -193,7 +193,7 @@ describe('get_device_app_path plugin', () => { |
193 | 193 | '-destination', |
194 | 194 | 'generic/platform=watchOS', |
195 | 195 | '-derivedDataPath', |
196 | | - DERIVED_DATA_DIR, |
| 196 | + computeScopedDerivedDataPath('/path/to/project.xcodeproj'), |
197 | 197 | ], |
198 | 198 | logPrefix: 'Get App Path', |
199 | 199 | useShell: false, |
@@ -251,7 +251,7 @@ describe('get_device_app_path plugin', () => { |
251 | 251 | '-destination', |
252 | 252 | 'generic/platform=iOS', |
253 | 253 | '-derivedDataPath', |
254 | | - DERIVED_DATA_DIR, |
| 254 | + computeScopedDerivedDataPath('/path/to/workspace.xcworkspace'), |
255 | 255 | ], |
256 | 256 | logPrefix: 'Get App Path', |
257 | 257 | useShell: false, |
@@ -343,6 +343,60 @@ describe('get_device_app_path plugin', () => { |
343 | 343 | expect(result.nextStepParams).toBeUndefined(); |
344 | 344 | }); |
345 | 345 |
|
| 346 | + it('should use explicit derivedDataPath when resolving build settings', async () => { |
| 347 | + const calls: Array<{ |
| 348 | + args: string[]; |
| 349 | + logPrefix?: string; |
| 350 | + useShell?: boolean; |
| 351 | + opts?: { cwd?: string }; |
| 352 | + }> = []; |
| 353 | + |
| 354 | + const mockExecutor = ( |
| 355 | + args: string[], |
| 356 | + logPrefix?: string, |
| 357 | + useShell?: boolean, |
| 358 | + opts?: { cwd?: string }, |
| 359 | + _detached?: boolean, |
| 360 | + ) => { |
| 361 | + calls.push({ args, logPrefix, useShell, opts }); |
| 362 | + return Promise.resolve( |
| 363 | + createMockCommandResponse({ |
| 364 | + success: true, |
| 365 | + output: |
| 366 | + 'Build settings for scheme "MyScheme"\n\nBUILT_PRODUCTS_DIR = /path/to/build/Debug-iphoneos\nFULL_PRODUCT_NAME = MyApp.app\n', |
| 367 | + error: undefined, |
| 368 | + }), |
| 369 | + ); |
| 370 | + }; |
| 371 | + |
| 372 | + await runLogic(() => |
| 373 | + get_device_app_pathLogic( |
| 374 | + { |
| 375 | + projectPath: '/path/to/project.xcodeproj', |
| 376 | + scheme: 'MyScheme', |
| 377 | + derivedDataPath: '/custom/DerivedData', |
| 378 | + }, |
| 379 | + mockExecutor, |
| 380 | + ), |
| 381 | + ); |
| 382 | + |
| 383 | + expect(calls).toHaveLength(1); |
| 384 | + expect(calls[0].args).toEqual([ |
| 385 | + 'xcodebuild', |
| 386 | + '-showBuildSettings', |
| 387 | + '-project', |
| 388 | + '/path/to/project.xcodeproj', |
| 389 | + '-scheme', |
| 390 | + 'MyScheme', |
| 391 | + '-configuration', |
| 392 | + 'Debug', |
| 393 | + '-destination', |
| 394 | + 'generic/platform=iOS', |
| 395 | + '-derivedDataPath', |
| 396 | + '/custom/DerivedData', |
| 397 | + ]); |
| 398 | + }); |
| 399 | + |
346 | 400 | it('should include optional configuration parameter in command', async () => { |
347 | 401 | const calls: Array<{ |
348 | 402 | args: string[]; |
@@ -394,7 +448,7 @@ describe('get_device_app_path plugin', () => { |
394 | 448 | '-destination', |
395 | 449 | 'generic/platform=iOS', |
396 | 450 | '-derivedDataPath', |
397 | | - DERIVED_DATA_DIR, |
| 451 | + computeScopedDerivedDataPath('/path/to/project.xcodeproj'), |
398 | 452 | ], |
399 | 453 | logPrefix: 'Get App Path', |
400 | 454 | useShell: false, |
|
0 commit comments