Support single tests. Exclude conflicting xcodebuild parameters#19
Support single tests. Exclude conflicting xcodebuild parameters#19
Conversation
…cting xcodebuild parameters
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the iOS MCP server to support running specific individual tests and removes conflicting xcodebuild parameters. The changes add test discovery capabilities, improve parameter validation, and ensure proper xcodebuild command generation.
Key Changes:
- Added support for running specific tests via a new
testsarray parameter in the test tool - Added a new
list-teststool for discovering available tests in iOS projects - Enhanced validation to prevent conflicting xcodebuild parameters (xcodeproj + xcworkspace)
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/index.ts |
Added test discovery import, enhanced test tool with tests/target parameters, and new list-tests tool registration |
src/core/testRunner.ts |
Modified command generation to ensure workspace/project mutual exclusion and added test filtering support |
src/core/testDiscovery.ts |
New file implementing test discovery, validation, and formatting functionality |
src/core/taskOptions.ts |
Enhanced validation with mutual exclusion checks, test identifier format validation, and new parameter support |
src/__tests__/xcodebuildParameterValidation.test.ts |
Comprehensive test suite for xcodebuild parameter validation and command generation |
src/__tests__/testRunnerEnhanced.test.ts |
Test suite for enhanced test runner functionality with specific test filtering |
src/__tests__/taskOptions.test.ts |
Extended existing test suite with validation for new test and target parameters |
src/__tests__/e2eAiIntegration.test.ts |
Added integration tests for enhanced test functionality |
README.md |
Updated documentation to reflect new test filtering capabilities and list-tests tool |
src/core/testDiscovery.ts
Outdated
| const workspaceArg = options.xcworkspace ? `-workspace "${options.xcworkspace}"` : ""; | ||
| const projectArg = options.xcodeproj ? `-project "${options.xcodeproj}"` : ""; |
There was a problem hiding this comment.
The test discovery function doesn't enforce workspace/project mutual exclusion like the main test runner. This could generate invalid xcodebuild commands with both -workspace and -project flags when both options are provided.
src/core/testDiscovery.ts
Outdated
| const workspaceArg = options.xcworkspace ? `-workspace "${options.xcworkspace}"` : ""; | ||
| const projectArg = options.xcodeproj ? `-project "${options.xcodeproj}"` : ""; | ||
| const schemeArg = options.scheme ? `-scheme "${options.scheme}"` : ""; | ||
| const destinationArg = `-destination "${options.destination || "generic/platform=iOS Simulator"}"`; | ||
|
|
||
| // Use xcodebuild with -dry-run to get test discovery without running tests | ||
| const cmd = `xcodebuild test ${workspaceArg} ${projectArg} ${schemeArg} ${destinationArg} -dry-run`.replace(/\s+/g, " ").trim(); |
There was a problem hiding this comment.
This command construction will include both workspace and project arguments when both are provided, violating xcodebuild specifications. Use the same mutual exclusion logic as in testRunner.ts.
| const workspaceArg = options.xcworkspace ? `-workspace "${options.xcworkspace}"` : ""; | |
| const projectArg = options.xcodeproj ? `-project "${options.xcodeproj}"` : ""; | |
| const schemeArg = options.scheme ? `-scheme "${options.scheme}"` : ""; | |
| const destinationArg = `-destination "${options.destination || "generic/platform=iOS Simulator"}"`; | |
| // Use xcodebuild with -dry-run to get test discovery without running tests | |
| const cmd = `xcodebuild test ${workspaceArg} ${projectArg} ${schemeArg} ${destinationArg} -dry-run`.replace(/\s+/g, " ").trim(); | |
| // Only include one of -workspace or -project, never both | |
| let workspaceOrProjectArg = ""; | |
| if (options.xcworkspace) { | |
| workspaceOrProjectArg = `-workspace "${options.xcworkspace}"`; | |
| } else if (options.xcodeproj) { | |
| workspaceOrProjectArg = `-project "${options.xcodeproj}"`; | |
| } | |
| const schemeArg = options.scheme ? `-scheme "${options.scheme}"` : ""; | |
| const destinationArg = `-destination "${options.destination || "generic/platform=iOS Simulator"}"`; | |
| // Use xcodebuild with -dry-run to get test discovery without running tests | |
| const cmd = `xcodebuild test ${workspaceOrProjectArg} ${schemeArg} ${destinationArg} -dry-run`.replace(/\s+/g, " ").trim(); |
src/core/testDiscovery.ts
Outdated
| // Look for test method patterns in the output | ||
| // xcodebuild dry-run typically shows lines like: | ||
| // "Test Case '-[MyAppTests.LoginTest testValidLogin]' started." | ||
| const testCasePattern = /Test Case '-\[([^.]+)\.([^.\s]+)\s+([^]]+)\]'/g; |
There was a problem hiding this comment.
The regex pattern uses [^] which matches any character including newlines, but the comment and context suggest this should match method names. Consider using a more specific pattern like ([^\\]]+) to match until the closing bracket.
No description provided.