Skip to content

Development and Testing

André Borchert edited this page Aug 14, 2026 · 15 revisions

Development and Testing

The project uses SwiftPM and Swift Testing on macOS 26 with Xcode 26.6 or later and Swift 6.3.3 or later. Both manifests use Swift language mode 6. Run commands from the repository root unless a section says otherwise.

Build

swift package resolve
swift build

The nested package can be built independently:

cd Swift
swift package resolve
swift build

Formatting is described by .swift-format at the repository root, matching the existing house style (four-space indentation, 160-column lines):

swift format lint --recursive --parallel Swift/Sources Swift/Tests

CI runs this as an advisory step rather than a gate. Making it blocking would require reformatting the whole tree in one commit, which would obscure history for no correctness gain; promote it once that reformat is done deliberately.

Every target opts into Swift strict memory-safety checking. CI also treats warnings as errors and enforces complete concurrency checking plus explicit Sendable declarations. Reproduce that diagnostic build locally with:

./Swift/check-toolchain.sh
swift build \
  -Xswiftc -warnings-as-errors \
  -Xswiftc -strict-concurrency=complete \
  -Xswiftc -require-explicit-sendable

Tests

Run the complete root-package suite:

swift test

Useful focused suites:

swift test --filter WebTransportHTTP3CoreTests
swift test --filter WebTransportTLSCoreTests
swift test --filter WebTransportNetworkRuntimeTests
swift test --filter WebTransportTests

Test targets and their primary scope:

Target Coverage
WebTransportTests Public API, separate processes, loopback networking, stress, release artifacts, and compatibility integration.
WebTransportNetworkRuntimeTests Runtime lifecycle, endpoint handling, deterministic network support, and hardening.
WebTransportHTTP3CoreTests HTTP/3, QPACK, sessions, streams, datagrams, flow control, limits, and malformed input.
WebTransportQUICCoreTests QUIC state, codecs, ACK/loss behavior, malformed input, and property corpora.
WebTransportTLSCoreTests TLS messages, state, key schedule, trust gating, exporter behavior, and hardening.
WebTransportCryptoAppleTests Initial-key derivation and packet protection.
WebTransportUDPAppleTests IPv4/IPv6 loopback and cancellation behavior.

Fuzzing peer-facing parsers

Every parser that consumes peer bytes is driven with a mechanically generated corpus, asserting only that it returns or throws and never traps. A trap in any of them is remotely reachable, because they all run before a session exists.

swift test --filter 'peerFacingParsers|huffmanDecoder'
WEBTRANSPORT_FUZZ_ITERATIONS=20000 swift test --sanitize=address \
  --filter 'peerFacingParsers|huffmanDecoder'

The generator is seeded and deterministic, so a CI failure replays exactly. The suite runs a small budget on every build; a CI job runs the large one under AddressSanitizer.

Sanitizers

swift test --sanitize=thread --skip CLIProcess --skip ReleaseArtifacts

The CLI process and release-artifact suites are excluded because they orchestrate subprocesses against wall-clock timeouts that the sanitizer's slowdown exceeds, which reports as a timeout rather than a race. The in-process runtime, protocol, and crypto tests are where shared mutable state actually lives.

Soak

./Swift/run-soak.sh 400

Drives sustained connection churn and judges session construction against destruction. Resident memory is reported for context only: a freed session's pages stay with the allocator, so RSS remains elevated long after the objects are gone and cannot by itself distinguish a leak from a warm heap. Growth during churn is expected while abandoned work holds sessions for its wait window.

Command-line conformance

swift run WebTransportClient --scenario all
swift run WebTransportServer --scenario all

Each executable runs the same 40-scenario positive and negative protocol matrix. Use --list to inspect scenario names and --help for command syntax.

API and release validation

cd Swift
./check-api-compatibility.sh
./build-release-apple-silicon.sh

The compatibility script builds an external package that imports the public products. The release script performs two clean arm64 builds, checks architecture and product selection, compares normalized binary hashes, and writes WebTransportClient, WebTransportServer, and SHA256SUMS under .build/release-artifacts/. Package tests and CI smoke-test those artifacts.

Validation by change type

Change Minimum evidence
Documentation Source/config fact check, local and Wiki link checks, rendered Markdown review.
Public API Build, complete tests, API compatibility script, DocC conversion.
CLI Complete tests and both conformance suites.
Runtime or trust Runtime/public API/process tests plus IPv4 and IPv6 packet loopback.
HTTP/3, QPACK, or sessions HTTP3Core tests and relevant conformance scenarios.
QUIC, TLS, crypto, or UDP Owning target tests plus an integration path.
A parser reading peer bytes The fuzz suite, plus a case covering the new shape.
Concurrency or task lifetime Thread Sanitizer, plus the soak when connection state is involved.
Anything a peer negotiates ./Swift/run-docker-interop.sh, since our own client agrees with us by construction.
Release tooling Reproducible release build and CI review.
Interoperability The appropriate runner from [[Release and Interoperability

The interoperability row is not a formality. Every internal test exercises this implementation against itself, so a defect both sides share is invisible to all of them. Two HTTP/3 critical-stream violations survived 227 tests and 80 conformance scenarios and were caught by the first run against a browser.

Environment-sensitive checks must be reported precisely. Do not reuse old generated artifacts as evidence for a new code revision.

Contributor workflow

  1. Identify the owning module and read its nearest tests.
  2. Check public API, protocol, trust, logging, manifest, CI, and documentation effects.
  3. Make the smallest coherent change and cover important negative paths.
  4. Run focused checks, then the broader validation required by the change.
  5. Review the final diff for generated output, credentials, stale claims, and unrelated edits.
  6. Update documentation whenever setup, API, behavior, trust, workflow, or release evidence changes.

Clone this wiki locally