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