Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [Unreleased]

### Fixed

- Fixed `swift_package_build`, `swift_package_test`, and `swift_package_clean` swallowing compiler diagnostics on failure by treating empty stderr as falsy, so stdout diagnostics are included in the error response ([#243](https://github.com/getsentry/XcodeBuildMCP/issues/243)).

## [2.1.0]

### Added
Expand Down
26 changes: 26 additions & 0 deletions src/mcp/tools/swift-package/__tests__/swift_package_build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,32 @@ describe('swift_package_build plugin', () => {
});
});

it('should include stdout diagnostics when stderr is empty on build failure', async () => {
const executor = createMockExecutor({
success: false,
error: '',
output:
"main.swift:10:25: error: cannot find type 'DOESNOTEXIST' in scope\nlet broken: DOESNOTEXIST = 42",
});

const result = await swift_package_buildLogic(
{
packagePath: '/test/package',
},
executor,
);

expect(result).toEqual({
content: [
{
type: 'text',
text: "Error: Swift package build failed\nDetails: main.swift:10:25: error: cannot find type 'DOESNOTEXIST' in scope\nlet broken: DOESNOTEXIST = 42",
},
],
isError: true,
});
});

it('should handle spawn error', async () => {
const executor = async () => {
throw new Error('spawn ENOENT');
Expand Down
26 changes: 26 additions & 0 deletions src/mcp/tools/swift-package/__tests__/swift_package_test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,32 @@ describe('swift_package_test plugin', () => {
});
});

it('should include stdout diagnostics when stderr is empty on test failure', async () => {
const mockExecutor = createMockExecutor({
success: false,
error: '',
output:
"main.swift:10:25: error: cannot find type 'DOESNOTEXIST' in scope\nlet broken: DOESNOTEXIST = 42",
});

const result = await swift_package_testLogic(
{
packagePath: '/test/package',
},
mockExecutor,
);

expect(result).toEqual({
content: [
{
type: 'text',
text: "Error: Swift package tests failed\nDetails: main.swift:10:25: error: cannot find type 'DOESNOTEXIST' in scope\nlet broken: DOESNOTEXIST = 42",
},
],
isError: true,
});
});

it('should handle spawn error', async () => {
const mockExecutor = async () => {
throw new Error('spawn ENOENT');
Expand Down
2 changes: 1 addition & 1 deletion src/mcp/tools/swift-package/swift_package_build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function swift_package_buildLogic(
try {
const result = await executor(['swift', ...swiftArgs], 'Swift Package Build', false, undefined);
if (!result.success) {
const errorMessage = result.error ?? result.output ?? 'Unknown error';
const errorMessage = result.error || result.output || 'Unknown error';
return createErrorResponse('Swift package build failed', errorMessage);
}

Expand Down
2 changes: 1 addition & 1 deletion src/mcp/tools/swift-package/swift_package_clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function swift_package_cleanLogic(
try {
const result = await executor(['swift', ...swiftArgs], 'Swift Package Clean', false, undefined);
if (!result.success) {
const errorMessage = result.error ?? result.output ?? 'Unknown error';
const errorMessage = result.error || result.output || 'Unknown error';
return createErrorResponse('Swift package clean failed', errorMessage);
}

Expand Down
2 changes: 1 addition & 1 deletion src/mcp/tools/swift-package/swift_package_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function swift_package_testLogic(
try {
const result = await executor(['swift', ...swiftArgs], 'Swift Package Test', false, undefined);
if (!result.success) {
const errorMessage = result.error ?? result.output ?? 'Unknown error';
const errorMessage = result.error || result.output || 'Unknown error';
return createErrorResponse('Swift package tests failed', errorMessage);
}

Expand Down
Loading