SwiftVM: Swift tests and coverage
Run Swift Testing suites and capture LLVM code coverage inside disposable Apple
Silicon macOS 27 virtual machines using the optional SwiftVM
provider (darwin-arm64). Provisioned guests include Command Line Tools 27.0
(Swift 6.4, swiftbuild, and llvm-cov export format 3.0.1), so Swift
packages build and test cleanly without Xcode.
Interactive walkthrough: Explore Swift Testing and LLVM coverage workflows.
Two workflows are supported:
- Your Swift packages in Reflow flows (
vm.guest_run): Stage your package and test script by digest, build with--enable-code-coverage, export binaries, xunit results, and raw.profrawprofiles under workspaceout/, and ingest full coverage on the host with Reflow LLVM code coverage. - Built-in fixture verification (
svm run): Build and run SwiftVM’s reference AppKit + Swift Testing fixture via thesvmhost tool to verify template toolchains, xunit integrity, host re-hashing, andllvm-covsummary parity.
One provider, SwiftVM (flow alias vm), covers this page and
SwiftVM: macOS VM, which describes templates, guest jobs,
off-screen display capture, and host setup.
Host requirements
Section titled “Host requirements”The macOS VM host requirements apply in full. In short:
- An Apple Silicon Mac on physical hardware (no nested macOS virtualization), running macOS 27, with guests on macOS 27 or later.
- A logged-in graphical session on the host. Virtual machines run on an offscreen display by default, so nothing appears on the desktop, but the session’s window server is still needed.
- Command Line Tools 27.0 on the host (Swift 6.4, SDK 27.0); provisioning installs its own copy in the guest. About 100 GB of free disk for first-time setup.
- The host tool signed with the
com.apple.security.virtualizationentitlement. - Direct HTTPS from the guest to Apple’s software update servers while the template is provisioned.
How tests run
Section titled “How tests run”The guest has Command Line Tools, not Xcode, so tests use Swift Testing
only. XCTest and .xcresult bundles are not supported.
Inside the guest, svm builds the package with Swift Build and
coverage enabled (passing the package and scratch paths, the Swift Testing macro
plugin path, and rpaths to the Command Line Tools testing libraries):
swift build --build-system swiftbuild --build-tests --enable-code-coverageThe tests then run through the toolchain’s swiftpm-testing-helper with
--testing-library swift-testing, writing xunit XML.
svm run validates SwiftVM’s built-in reference fixture (an AppKit app with
passing, failing, and slow suites for timeout/cancellation checks). To run your
own Swift packages inside Reflow flows, stage and execute them as vm.guest_run
jobs and export xunit XML and coverage profiles through workspace out/.
Results
Section titled “Results”Test results are accepted only in a pinned xunit dialect from the Command Line Tools 27.0 / Swift 6.4 helper. Test identities must match exactly and summaries must be consistent; errors, skipped tests, duplicates and malformed counts are refused. If a template records a different Command Line Tools or Swift version, the run warns and adds a limitation to its report.
Artifacts are listed by the guest with their sizes and SHA-256 hashes and re-hashed on the host. A failed or mismatched transfer is recorded as corrupt and its partial file is deleted. The selected tests must come with the test bundle they were linked into. This proves the artifacts were transferred intact and that the evidence is consistent. It does not prove the guest is honest: the guest can fabricate results, and untrusted job code is not supported.
The run’s verdict and exit code are described on the macOS VM page.
Coverage
Section titled “Coverage”When coverage is requested:
- Each test process writes a raw profile named
<name>-%p.profraw. - In the guest,
llvm-profdata merge -sparsemerges them andllvm-cov export -summary-onlywrites a summary. - On the host,
llvm-cov export -summary-onlyruns again over the guest’s merged profile and binary, and its summary is validated.
Command Line Tools 27’s llvm-cov writes export format 3.0.1, which svm
validates.
A run that requests coverage never passes: at best it ends incomplete (exit 4), even when every test and coverage-integrity check passes. A failed check, unconfirmed cleanup or an interrupt gives that run’s usual exit code instead. There is no coverage policy, no default threshold, and no complete record tying the source, the build and the profiles together. Missing policy or provenance is never treated as a pass.
Coverage has one more trust limit: the host’s llvm-cov parses profiles and
binaries produced inside the guest, and that parsing is not sandboxed.
Reflow code coverage
Section titled “Reflow code coverage”The fixture’s summary-only coverage export is not a canonical Reflow coverage document: it lacks full per-file and per-function data, and no automatic fixture adapter exists. Its incomplete coverage verdict remains unchanged.
For vm.guest_run, build an instrumented app, retain its exact binaries and
profiles under workspace out/, then bind and ingest the exported coverage on
the host. A guest job passing does not itself ingest coverage or prove a coverage
policy. See Swift and other LLVM languages
for the required full llvm-cov export and process counts. The CLI accepts export
formats 2.0.1 and 3.0.1, including Command Line Tools 27’s format.
Limits
Section titled “Limits”- Swift Testing only: Guests carry Command Line Tools 27 rather than Xcode, so XCTest and
.xcresultbundles are not supported. - Host tool: Template provisioning and built-in fixture verification use the
svmhost tool built from source; provisioning requires direct outbound HTTPS for Command Line Tools. - Custom packages: Run your own Swift packages via
vm.guest_runjobs and ingest full coverage on the host viareflow coverage ingest --format llvm-cov(there is no separate Reflow-level Swift Testing adapter command). - Fixture coverage mode:
svm runcoverage is a diagnostic check (exits 4 at best) and does not substitute for fullllvm-covingestion into Reflow code coverage.