Skip to content

Commit 33e3c2f

Browse files
committed
fix: improve snapshot normalization and update fixtures
- Fix test summary regex to preserve "tests" word in failure counts - Normalize doctor cwd, axe video capture capability - Update fixtures for bundle ID change (MCPTest.macOS) and improved tmpdir/test-count normalization
1 parent b6bfc1c commit 33e3c2f

File tree

8 files changed

+23
-10
lines changed

8 files changed

+23
-10
lines changed

src/snapshot-tests/__fixtures__/macos/build--success.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Derived Data: <HOME>/Library/Developer/XcodeBuildMCP/DerivedData
99

1010
✅ Build succeeded. (⏱️ <DURATION>)
11-
├ Bundle ID: io.sentry.calculatorapp
11+
├ Bundle ID: io.sentry.MCPTest.macOS
1212
└ Build Logs: <HOME>/Library/Developer/XcodeBuildMCP/logs/build_macos_<TIMESTAMP>_pid<PID>.log
1313

1414
Next steps:

src/snapshot-tests/__fixtures__/macos/build-and-run--success.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
✅ Build succeeded. (⏱️ <DURATION>)
1616
✅ Build & Run complete
1717
├ App Path: <HOME>/Library/Developer/XcodeBuildMCP/DerivedData/Build/Products/Debug/MCPTest.app
18-
├ Bundle ID: io.sentry.calculatorapp
18+
├ Bundle ID: io.sentry.MCPTest.macOS
1919
├ Process ID: <PID>
2020
└ Build Logs: <HOME>/Library/Developer/XcodeBuildMCP/logs/build_run_macos_<TIMESTAMP>_pid<PID>.log
2121

src/snapshot-tests/__fixtures__/macos/launch--success.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
App: <HOME>/Library/Developer/XcodeBuildMCP/DerivedData/Build/Products/Debug/MCPTest.app
55

66
✅ App launched successfully
7-
├ Bundle ID: io.sentry.calculatorapp
7+
├ Bundle ID: io.sentry.MCPTest.macOS
88
└ Process ID: <PID>

src/snapshot-tests/__fixtures__/resources/doctor--success.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Node.js Information
2222
ppid: <PID>
2323
platform: darwin
2424
arch: arm64
25-
cwd: /Users/<redacted>/.codex/worktrees/43f4/<redacted>
25+
cwd: <CWD>
2626
argv: <ARGV>
2727

2828
Process Tree
@@ -59,7 +59,7 @@ PATH
5959
UI Automation (axe)
6060
Available: Yes
6161
UI Automation Supported: Yes
62-
Simulator Video Capture Supported (AXe >= 1.1.0): No
62+
Simulator Video Capture Supported (AXe >= <VERSION>): <AVAILABLE>
6363
UI-Debugger Guard Mode: error
6464

6565
Incremental Builds

src/snapshot-tests/__fixtures__/simulator/screenshot--success.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
Simulator: <UUID>
55

66
✅ Screenshot captured
7-
├ Screenshot: /var/folders/_t/2njffz894t57qpp76v1sw__h0000gn/T/screenshot_optimized_<UUID>.jpg
7+
├ Screenshot: <TMPDIR>
88
├ Format: image/jpeg
99
└ Size: 368x800px

src/snapshot-tests/__fixtures__/simulator/test--failure.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ IntentionalFailureTests
1717
- XCTAssertTrue failed - This test should fail to verify error reporting
1818
example_projects/iOS_Calculator/CalculatorAppTests/CalculatorAppTests.swift:286
1919

20-
2 tests failed, 21 passed, 0 skipped (⏱️ <DURATION>)
20+
<FAIL_COUNT> tests failed, <PASS_COUNT> passed, <SKIP_COUNT> skipped (⏱️ <DURATION>)
2121
└ Build Logs: <HOME>/Library/Developer/XcodeBuildMCP/logs/test_sim_<TIMESTAMP>_pid<PID>.log

src/snapshot-tests/__fixtures__/swift-package/test--failure.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ CalculatorAppTests
1717
Test failed
1818
SimpleTests.swift:57
1919

20-
2 tests failed, 5 passed, 0 skipped (⏱️ <DURATION>)
20+
<FAIL_COUNT> tests failed, <PASS_COUNT> passed, <SKIP_COUNT> skipped (⏱️ <DURATION>)
2121
└ Build Logs: <HOME>/Library/Developer/XcodeBuildMCP/logs/swift_package_test_<TIMESTAMP>_pid<PID>.log

src/snapshot-tests/normalize.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ export function normalizeSnapshotOutput(text: string): string {
149149

150150
normalized = normalized.replace(COVERAGE_CALL_COUNT_REGEX, 'called <N>x)');
151151

152+
// Normalize final test summary line (counts vary across environments)
153+
normalized = normalized.replace(
154+
/\d+ (tests? failed), \d+ (passed)(?:, \d+ (skipped))?/g,
155+
'<FAIL_COUNT> $1, <PASS_COUNT> $2, <SKIP_COUNT> skipped',
156+
);
157+
152158
normalized = normalized.replace(
153159
/("(?:x|y|width|height)"\s*:\s*)(\d+\.\d{2,})/g,
154160
(_, prefix, num) => `${prefix}${parseFloat(num).toFixed(1)}`,
@@ -179,15 +185,22 @@ export function normalizeSnapshotOutput(text: string): string {
179185
' selectedXcode: <XCODE_PATH>',
180186
);
181187
normalized = normalized.replace(/ xcrunVersion: xcrun version .+/g, ' xcrunVersion: <VERSION>');
182-
normalized = normalized.replace(/ axe: [\d.]+[^\n]*/g, ' axe: <VERSION>');
183-
normalized = normalized.replace(/ mise: [\d.]+[^\n]*/g, ' mise: <VERSION>');
188+
normalized = normalized.replace(/ axe: v?[\d.]+[^\n]*/g, ' axe: <VERSION>');
189+
normalized = normalized.replace(/ mise: v?[\d.]+[^\n]*/g, ' mise: <VERSION>');
184190
normalized = normalized.replace(
185191
/ mcpbridge path: \/Applications\/Xcode[^\n]+/g,
186192
' mcpbridge path: <XCODE_PATH>',
187193
);
188194
normalized = normalized.replace(/ Total Unique Tools: \d+/g, ' Total Unique Tools: <COUNT>');
189195
normalized = normalized.replace(/ Workflow Count: \d+/g, ' Workflow Count: <COUNT>');
190196
normalized = normalized.replace(/ (\w[\w-]*): \d+ tools$/gm, ' $1: <N> tools');
197+
// Sanitize cwd (volatile across environments — local dev, codex worktrees, CI)
198+
normalized = normalized.replace(/ cwd: [^\n]+/g, ' cwd: <CWD>');
199+
// Sanitize environment-dependent capability flags
200+
normalized = normalized.replace(
201+
/Simulator Video Capture Supported \(AXe >= [\d.]+\): (?:Yes|No)/g,
202+
'Simulator Video Capture Supported (AXe >= <VERSION>): <AVAILABLE>',
203+
);
191204
// Sanitize the entire PATH section (volatile across environments)
192205
normalized = normalized.replace(/\nPATH\n(?: [^\n]+\n)*/g, '\nPATH\n <PATH_ENTRIES>\n');
193206

0 commit comments

Comments
 (0)