fix(tests): make the PilotTests target compile and run - #15
Merged
Conversation
The test target failed to build, so `swift test` reported 0 tests run:
* Three `switch pe { ... }` over `Pilot.Error` predated the
`.dataTooLarge` case and were no longer exhaustive
(StartErrorPathTests x2, IntegrationTests x1).
* `testPortTruncationDetection` sat after the closing brace of
`DatagramTests`, at file scope, and compared `NSNumber.uint16Value`
against `NSNumber.uint64Value` inside `XCTAssertEqual` — which binds
both arguments to one generic parameter and cannot mix UInt16/UInt64.
Changes:
* Add the missing `.dataTooLarge` cases; extend ErrorTests to cover its
description and case-distinctness.
* Move `testPortTruncationDetection` inside `DatagramTests` and point it
at the real decode path instead of re-implementing the check: split
`Pilot.decodeDatagram(_:)` out of `receive()` and validate ports by
range-checking a single signed 64-bit value. `uint16Value` wraps, so
70000 previously read back as 4464 and -1 as 65535; both are now
rejected with `.invalidResponse`.
* Add `Pilot.attach(driverHandle:start:)` (internal) so MockDaemonTests
can drive the public `send()` / `receive()` wrapper over the mock
daemon's SendTo->RecvFrom loopback rather than only the C symbols.
`stop()` closes the embedded daemon only for instances that started it.
* Build the mock daemon with GOWORK=off — it is a nested module, and a
go.work higher up the tree made `go build` fail, silently skipping all
14 MockDaemonTests.
swift test: 49 tests, 6 skipped (opt-in PILOT_INTEGRATION), 0 failures.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Problem
The
PilotTeststarget did not compile, soswift testwas red and 0 tests ran.Six compile errors, three distinct causes:
Pilot.Error—.dataTooLargewas added to the enum but threeswitchstatements in the tests were never updated (StartErrorPathTests.swift:84,:135,IntegrationTests.swift:73).testPortTruncationDetectionwas at file scope, after the closing brace ofDatagramTests— XCTest could never have discovered it even if it compiled.NSNumbercomparisons —XCTAssertEqual(n.uint16Value, n.uint64Value)binds both arguments to a single generic parameterT, soUInt16vsUInt64is a hard error. (The same expression compiles inPilot.swiftonly because the stdlib has heterogeneous==forBinaryInteger.)Changes
.dataTooLargecases in all three switches; extendedErrorTeststo cover itsdescriptionand case-distinctness.testPortTruncationDetectioninsideDatagramTestsand pointed it at the real decode path instead of re-implementing the check inline.Pilot.decodeDatagram(_:)is split out ofreceive()(which now just calls it) and ports are validated by range-checking a single signed 64-bit value.NSNumber.uint16Valuewraps, so70000read back as4464and-1as65535; both are now rejected with.invalidResponse. Added decode tests for missing/mistyped fields and the raw-byte-array / empty-data fallbacks.Pilot.attach(driverHandle:start:)soMockDaemonTestscan drive the publicsend()/receive()wrapper over the mock daemon's SendTo→RecvFrom loopback, not just the raw C symbols.stop()now tears down the embedded daemon only for instances that started it. NewtestWrapperSendReceiveRoundtripactually callsreceive()and asserts the round-tripped payload and ports.GOWORK=off. It is a nested Go module, and ago.workhigher up the tree madego buildfail with "main module does not contain package …", which silently skipped all 14MockDaemonTests.Verification
The 6 skips are the opt-in daemon-backed tests that require
PILOT_INTEGRATION=1and a reachable registry. All 14MockDaemonTestsnow run (previously all skipped).🤖 Generated with Claude Code