Skip to content

Comments

Support single tests. Exclude conflicting xcodebuild parameters#19

Merged
a-25 merged 3 commits intomainfrom
upgrade_ui_tests
Sep 1, 2025
Merged

Support single tests. Exclude conflicting xcodebuild parameters#19
a-25 merged 3 commits intomainfrom
upgrade_ui_tests

Conversation

@a-25
Copy link
Owner

@a-25 a-25 commented Aug 27, 2025

No description provided.

Copilot AI review requested due to automatic review settings August 27, 2025 16:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 tests array parameter in the test tool
  • Added a new list-tests tool 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

Comment on lines 26 to 27
const workspaceArg = options.xcworkspace ? `-workspace "${options.xcworkspace}"` : "";
const projectArg = options.xcodeproj ? `-project "${options.xcodeproj}"` : "";
Copy link

Copilot AI Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 26 to 32
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();
Copy link

Copilot AI Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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();

Copilot uses AI. Check for mistakes.
// 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;
Copy link

Copilot AI Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@a-25 a-25 merged commit 9e3d102 into main Sep 1, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant