Support command-line arguments and XCTest filters without forcing xcodebuild in ios_xctestrun_runner

Open
#3,129 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active

Research direction

Start by locating ios_xctestrun_runner and comparing the direct xctest and xcodebuild test-without-building branches. Check how command_line_args and test filters are parsed, then find the runner tests that cover backend selection. Done means representable arguments and XCTest selections use direct execution while cases it cannot handle still select xcodebuild; add or update tests for both paths.

Written by the indexing model from the issue text.

Description

Allow hostless iOS simulator XCTest bundles to continue using direct xctest execution when supplying command-line arguments or test selections that xctest can handle.

Currently, ios_xctestrun_runner switches to xcodebuild test-without-building whenever command_line_args or a test filter is supplied. The direct execution branch always invokes:

xcrun simctl spawn <simulator-udid> <xctest-binary> \
  -XCTest All <test-bundle>

However, direct xctest execution supports useful arguments and test selection, so these inputs do not always require switching execution backends.

Use cases

1. Language, locale, and text-direction overrides

-AppleLanguages '(en_GB)' -AppleLocale en_US -AppleTextDirection NO

Apple documents these launch arguments in Testing Your Internationalized App, alongside arguments for testing right-to-left layouts, double-length localized strings, and detecting non-localized strings.

Passing preferences per invocation avoids changing persistent simulator preferences.

2. Custom test configuration

Test code or its dependencies may read startup arguments through CommandLine.arguments, ProcessInfo, or argument-domain preferences-for example, to select fixtures or enable test-specific behavior.

3. Running selected XCTest classes or methods

The documented xctest -XCTest option supports class and method identifiers, including comma-separated selections. Running one test, one class, or several selected tests should be able to retain direct execution where the selection is representable.

These cases are particularly useful for short hostless test bundles, where switching to xcodebuild introduces additional startup and orchestration work.

Example

Given an otherwise directly executable hostless XCTest target:

bazel test //tests:ExampleTests \
  --test_arg="--command_line_args=-AppleLanguages,(en_GB),-AppleLocale,en_US"

Or:

bazel test //tests:ExampleTests \
  --test_filter=ExampleTests/testExample

Both currently select xcodebuild, even when no other requested feature requires it.

Dominant language
Starlark
Stars
600
Forks
354
Avg merge
2d 7h
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazelbuild/rules_apple

All issues in bazelbuild/rules_apple

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.