Repository navigation
Add buildtool test to run Xcode unit-test targets with xctest - #24
Merged
Merged
Conversation
`buildtool test` builds the project, then runs each unit-test target's .xctest bundle with tools-xctest's xctest, like `xcodebuild test`. Targets come from -target, a scheme (its testables, SkippedTests and SelectedTests), or every unit-test target; xcodebuild's -only-testing and -skip-testing select tests. For test, -target and -scheme choose test targets instead of narrowing the build, so test hosts still get built. XCTEST picks the xctest program and XCTEST_FLAGS adds options. A failed build or test fails the action, and so buildtool's exit status. It works with tools-xctest as it is: -only-testing becomes an -XCTest Class[.method] selection. Skipping tests and running a target inside the application its TEST_HOST names need xctest's -skip-testing and -host, which newer tools-xctest has; buildtool uses them when xctest --help lists them, and otherwise fails that target with a message saying what is missing. Testing: Tests/run-buildtool-test-action.sh runs `buildtool test` on a new fixture project (a tool, its tests, an application and tests hosted in it): the full run, a failing test, -only-testing by method and by class, -skip-testing, a scheme's testables and skipped tests, the hosted target, and the mistakes (a non-test target, an unknown scheme). It checks which test methods ran by name, so it doesn't depend on xctest's output format, and expects the "needs an xctest with ..." failure where the xctest lacks an option. It passes against xctest from gnustep/tools-xctest master, from master plus the -only-testing and -skip-testing patch, and from a build that also has -host. Against master's buildtool it fails at the first check. AI assistance: this change, its test and this description were written with Claude (Anthropic's Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
I will accept this. I need to make sure have you signed a copyright assignment? Please write request-assign@gnu.org and ask for one for GNUstep. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
buildtool testbuilds the project, likexcodebuild test, then runs each unit-test target's.xctestbundle withxctestfrom tools-xctest:Targets come from
-target, from a scheme (its testables, with itsSkippedTestsandSelectedTests), or are every unit-test target. Fortest,-targetand-schemechoose the test targets rather than narrowing the build, so an application that tests are hosted in still gets built.XCTESTchooses thexctestprogram andXCTEST_FLAGSpasses extra options to it. A failed build or a failed test fails the action, and so buildtool's exit status.It works with tools-xctest as it is today:
-only-testing:becomes an-XCTest Class[.method]selection. Two things need newer xctest options: skipping tests (-skip-testing:or a scheme's skipped tests) needs-skip-testing, and a test target whoseTEST_HOSTnames an application in the project needs-hostto run inside it. buildtool asksxctest --helpand uses those options when they're listed; otherwise it fails that target with a message saying what's missing. (-skip-testingis in #5 on tools-xctest;-hostwould come later.)The code is a new
PBXProject (Testing)category (XCode/PBXProject+Testing.[hm]).PBXContainergains-setTestOptions:and-test, andToolDelegategains thetestaction and its options.Testing:
Tests/run-buildtool-test-action.shrunsbuildtool teston a new fixture project,Tests/Fixtures/Xcode/unit-tests(Calc.xcodeproj: a tool, its unit tests, an application, and unit tests hosted in it;generate-project.pywrites its pbxproj). It covers:-only-testing:by method and by class;-skip-testing:;It checks which test methods ran by name, so it doesn't depend on xctest's output format. Where the xctest lacks an option, it expects the "needs an xctest with …" failure instead. It passes with xctest built from tools-xctest master, from master plus #5, and from a build that also has
-host. With current master's buildtool it fails at its first check, becausetestisn't an action there. The changed library and tool files and the fixture sources pass a syntax check with GCC's Objective-C front end. CalcTests.m passes it once the fixture'sHEADER_SEARCH_PATHS(Sources) is supplied.Run on Debian 13 amd64, clang 19.1.7, libobjc2 2.3, gnustep-base 1.31.1, gnustep-make 2.9.3.
AI assistance: this change, its test and this description were written with Claude (Anthropic's Claude Code).