Skip to content

Commit 6ba09ca

Browse files
committed
fix: address review feedback across remaining tools migration
- Restore dropped coverage calculation assertions in tests - Wrap runCommand 'process interrupt' in enqueue for thread safety - Add mapError to swift_package_test withErrorHandling to prevent double header emission on error - Wrap doctor runDoctor body in try/finally to restore env variable
1 parent bfdef45 commit 6ba09ca

4 files changed

Lines changed: 24 additions & 7 deletions

File tree

src/mcp/tools/coverage/__tests__/get_coverage_report.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ describe('get_coverage_report', () => {
181181
expect(result.isError).toBeUndefined();
182182
expect(result.content.length).toBeGreaterThanOrEqual(1);
183183
const text = allText(result);
184+
expect(text).toContain('Overall: 24.7%');
185+
expect(text).toContain('180/730 lines');
184186
const coreIdx = text.indexOf('Core');
185187
const appIdx = text.indexOf('MyApp.app');
186188
const testIdx = text.indexOf('MyAppTests.xctest');
@@ -218,6 +220,9 @@ describe('get_coverage_report', () => {
218220

219221
expect(result.isError).toBeUndefined();
220222
expect(result.content.length).toBeGreaterThan(0);
223+
const text = allText(result);
224+
expect(text).toContain('Core: 10.0%');
225+
expect(text).toContain('MyApp.app: 50.0%');
221226
});
222227
});
223228

src/mcp/tools/doctor/doctor.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export async function runDoctor(params: DoctorParams, deps: DoctorDependencies)
167167
const prevSilence = process.env.XCODEBUILDMCP_SILENCE_LOGS;
168168
process.env.XCODEBUILDMCP_SILENCE_LOGS = 'true';
169169
log('info', `${LOG_PREFIX}: Running doctor tool`);
170+
try {
170171

171172
const xcodemakeEnabled = deps.features.isXcodemakeEnabled();
172173
const requiredBinaries = ['axe', 'mise', ...(xcodemakeEnabled ? ['xcodemake'] : [])];
@@ -475,11 +476,6 @@ export async function runDoctor(params: DoctorParams, deps: DoctorDependencies)
475476

476477
events.push(statusLine('success', 'Doctor diagnostics complete'));
477478

478-
if (prevSilence === undefined) {
479-
delete process.env.XCODEBUILDMCP_SILENCE_LOGS;
480-
} else {
481-
process.env.XCODEBUILDMCP_SILENCE_LOGS = prevSilence;
482-
}
483479
const rendered = renderEvents(events, 'text');
484480
const hasError = events.some(
485481
(e) =>
@@ -491,6 +487,14 @@ export async function runDoctor(params: DoctorParams, deps: DoctorDependencies)
491487
isError: hasError || undefined,
492488
_meta: { events: [...events] },
493489
};
490+
491+
} finally {
492+
if (prevSilence === undefined) {
493+
delete process.env.XCODEBUILDMCP_SILENCE_LOGS;
494+
} else {
495+
process.env.XCODEBUILDMCP_SILENCE_LOGS = prevSilence;
496+
}
497+
}
494498
}
495499

496500
export async function doctorLogic(params: DoctorParams, executor: CommandExecutor) {

src/mcp/tools/swift-package/swift_package_test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ export async function swift_package_testLogic(
110110
header: headerEvent,
111111
errorMessage: ({ message }) => `Failed to execute swift test: ${message}`,
112112
logMessage: ({ message }) => `Swift package test failed: ${message}`,
113+
mapError: ({ message, headerEvent: hdr, emit }) => {
114+
if (emit) {
115+
emit(hdr);
116+
emit(statusLine('error', `Failed to execute swift test: ${message}`));
117+
}
118+
},
113119
},
114120
);
115121
}

src/utils/debugger/backends/dap-backend.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ class DapBackend implements DebuggerBackend {
137137

138138
const normalizedCommand = command.trim().toLowerCase();
139139
if (normalizedCommand === 'process interrupt') {
140-
await this.pauseExecution(opts?.timeoutMs);
141-
return 'Process interrupted.';
140+
return this.enqueue(async () => {
141+
await this.pauseExecution(opts?.timeoutMs);
142+
return 'Process interrupted.';
143+
});
142144
}
143145

144146
try {

0 commit comments

Comments
 (0)