-
-
Notifications
You must be signed in to change notification settings - Fork 313
Expand file tree
/
Copy pathsimulator-test-execution.test.ts
More file actions
94 lines (87 loc) · 3.16 KB
/
Copy pathsimulator-test-execution.test.ts
File metadata and controls
94 lines (87 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { describe, expect, it } from 'vitest';
import { createSimulatorTwoPhaseExecutionPlan } from '../simulator-test-execution.ts';
import type { TestPreflightResult } from '../test-preflight.ts';
function createPreflight(): TestPreflightResult {
return {
scheme: 'CalculatorApp',
configuration: 'Debug',
projectPath: '/tmp/CalculatorApp.xcodeproj',
destinationName: 'iPhone 17 Pro',
selectors: { onlyTesting: [], skipTesting: [] },
warnings: [],
completeness: 'complete',
totalTests: 2,
targets: [
{
name: 'CalculatorAppTests',
warnings: [],
files: [
{
path: '/tmp/CalculatorAppTests.swift',
tests: [
{
framework: 'xctest',
targetName: 'CalculatorAppTests',
typeName: 'CalculatorAppTests',
methodName: 'testAddition',
displayName: 'CalculatorAppTests/CalculatorAppTests/testAddition',
line: 10,
parameterized: false,
},
{
framework: 'swift-testing',
targetName: 'CalculatorAppTests',
typeName: 'ExpressionSuite',
methodName: 'evaluatesExpression',
displayName: 'CalculatorAppTests/ExpressionSuite/evaluatesExpression',
line: 20,
parameterized: true,
},
],
},
],
},
],
};
}
describe('createSimulatorTwoPhaseExecutionPlan', () => {
it('keeps preflight discovery observational instead of synthesizing only-testing selectors', () => {
const plan = createSimulatorTwoPhaseExecutionPlan({
extraArgs: ['-parallel-testing-enabled', 'YES'],
preflight: createPreflight(),
resultBundlePath: '/tmp/Calculator.xcresult',
});
expect(plan.buildArgs).toEqual(['-parallel-testing-enabled', 'YES']);
expect(plan.testArgs).toEqual([
'-parallel-testing-enabled',
'YES',
'-resultBundlePath',
'/tmp/Calculator.xcresult',
]);
expect(plan.usesExactSelectors).toBe(false);
});
it('preserves user-supplied selector arguments in both simulator test phases', () => {
const plan = createSimulatorTwoPhaseExecutionPlan({
extraArgs: [
'-only-testing:CalculatorAppTests/CalculatorAppTests/testAddition',
'-skip-testing',
'CalculatorAppTests/ExpressionSuite/evaluatesExpression',
],
preflight: createPreflight(),
});
expect(plan.buildArgs).toEqual([
'-only-testing:CalculatorAppTests/CalculatorAppTests/testAddition',
'-skip-testing',
'CalculatorAppTests/ExpressionSuite/evaluatesExpression',
]);
expect(plan.testArgs).toEqual(plan.buildArgs);
expect(plan.usesExactSelectors).toBe(true);
});
it('keeps resultBundlePath out of build-for-testing args and includes it for test-without-building', () => {
const plan = createSimulatorTwoPhaseExecutionPlan({
extraArgs: ['-resultBundlePath', '/tmp/UserProvided.xcresult'],
});
expect(plan.buildArgs).toEqual([]);
expect(plan.testArgs).toEqual(['-resultBundlePath', '/tmp/UserProvided.xcresult']);
});
});