Skip to content

Go, Swift, Dart and Zig

The static tier selects tests here from the import graph, and the safety rules still apply. Go, Swift and Dart/Flutter also have a recorded tier (record --coverage); Zig does not.

Runner: go test. A package is its directory, and imports are resolved against the module path, including go.work workspaces and replace directives. Go resolves imports at compile time, so the static graph is exact. With record --coverage (go test -coverprofile), selection is function-level: an edit to a function or method the test never ran selects nothing. Types, var/const/import, init and added or removed methods always count. Verified end to end against real go test.

Runner: swift test (SwiftPM). Static selection is module-level, from the SwiftPM target layout. With record --coverage, each test file runs with swift test --enable-code-coverage and is selected by the functions it executed. Xcode projects (*.xcodeproj) are a separate adapter, described below.

Objective-C sits beside Swift in the same adapter: the .m, .mm, .h, .c, .cpp, .hpp and .modulemap files of a SwiftPM target are tracked, and an XCTest class written in Objective-C is a test when it is in a test target and has a - (void)testX method (or is a *Tests : XCTestCase class). Edges come from @import Module;, #import <Module/Header.h> (the module), #import "path.h" (the including file’s directory, then any owned header that ends in that path, which is how a dependency’s public headers are found) and #import "Module-Swift.h" (the Swift half of a module). A Swift file that imports an Objective-C target already reaches all of its files. Comments and formatting do not count as a change; strings, macros and the line structure of preprocessor directives do (joining the next line onto a #define is a change). A test run uses --filter Target.Class for each @implementation. With record --coverage, Objective-C tests are recorded like Swift ones but tracked per file, not per function. Not covered: bridging headers of SwiftPM app targets, and Carthage layouts. Verified end to end against real swift test; a runner that hangs is killed by --timeout along with the xctest it started in its own session.

Runner: xcodebuild test. Each Foo.xcodeproj is its own project ([email protected]), read from project.pbxproj: the targets, the files each one builds (build phases, resources, and Xcode 16 synchronised folders with their exception lists), and how targets relate. A unit or UI test bundle (bundle.unit-test, bundle.ui-testing) holds the tests; XCTest and Swift Testing in Swift and XCTest in Objective-C are recognised the same way as in SwiftPM.

Selection is target-level, like SwiftPM’s. A test file depends on every file of its own target and of everything that target is built after, hosted by (TEST_HOST, BUNDLE_LOADER), drives (TEST_TARGET_NAME) or links, so an edit to any of those selects the test bundle’s tests. A source file reaches the tests through the modules and headers it is imported from. A file that no target builds cannot affect a test and selects nothing. Comments and formatting do not count; the Swift and Objective-C fingerprints are the SwiftPM ones.

These run the whole project, because they change how targets build and cannot be traced to a file: project.pbxproj (adding a file to a target is such a change), *.xcconfig, *.xctestplan, *.xcscheme, Info.plist, *.entitlements, Podfile.lock, Package.resolved, and anything inside a local Swift package the project uses.

A test is run through a shared scheme whose test action (or test plan) lists its bundle, as xcodebuild test -project Foo.xcodeproj -scheme S -destination ... -only-testing:Bundle/Class, one command per scheme. A test that no shared scheme runs is reported as unrunnable instead of being dropped: share the scheme (Product > Scheme > Manage Schemes > Shared). With a CocoaPods Podfile and a workspace of the same name, the workspace is built instead. The destination is this Mac for macOS targets and the newest installed simulator (a booted one first) for iOS, tvOS, watchOS and visionOS; set TRIMTEST_XCODE_DESTINATION (for example platform=iOS Simulator,name=iPhone 16) to choose one. [runner] xcode = "..." prefixes the command. Runs pass -collect-test-diagnostics never: after a failing test xcodebuild otherwise spends up to ten minutes collecting simulator diagnostics (simctl diagnose), and a failing test is the normal result of a run that found a change’s effect. Set TRIMTEST_XCODE_DIAGNOSTICS=on-failure to restore it, or empty to pass nothing.

With record --coverage each test file runs with -enableCodeCoverage YES and the result bundle is read with xccov: selection is function-level for Swift and file-level for Objective-C. Verified end to end against real xcodebuild (Xcode 27) on a macOS app with a hosted test bundle; iOS simulator destinations, UI tests and CocoaPods workspaces are built from the same code but were not run here. The bundled xcodeshop bench project (2 frameworks, a host app, 3 test bundles) had zero misses over 12 mutations, a delete, a rename and a broken project.pbxproj, static and recorded. Not covered: cross-project references (a target that depends on another .xcodeproj), XCFramework or binary targets, and run-script phases that generate sources.

Runners: flutter test or dart test. Edges come from import, export and part directives and package: URIs, including package: imports of path dependencies and pub workspace members. Plain integration_test/ files are not run by trimtest. Files calling patrolTest( (or in patrol_test/) are Patrol tests, run with patrol test --target <file> on a device and selected from the static graph only; android/, ios/, macos/, linux/, windows/, web/ and .patrol.env run everything. [[project]] kind accepts patrol, maestro, detox, android-instrumented, dotnet, elixir, ruby, php and sql to force these adapters.

With record --coverage (flutter test --coverage, dart test --coverage) selection is function-level: a testWidgets test that never builds a widget or calls a method is not selected when that code changes. Files with part/part of (including generated .g.dart and .freezed.dart) stay file-level.

Non-Dart inputs are handled conservatively:

  • Assets, fonts and shaders declared under flutter: in pubspec.yaml, any .arb file, pubspec.yaml, pubspec.lock, build.yaml, l10n.yaml, dart_test.yaml and analysis_options.yaml run every test of the package when they change, because Flutter loads them by name at run time.
  • A file a Dart source names with a string literal (a golden given to matchesGoldenFile, a fixture opened with File('test/fixtures/in.json')) selects the tests that import that source, and a recorded test that ran it. A golden named by an expression selects the test that uses it for any change beside it.

Verified end to end against real flutter test and dart test (Flutter 3.50 / Dart 3.14), and benchmarked on the Flutter team’s compass_app (see soundness).

Runner: zig build test. Edges come from @import("x.zig"), and inline test blocks count as tests. Named modules are not followed, so those changes are conservative. Covered by unit tests and --dry-run so far.