From bcdfba69ef711953c13fe5c1bfe3862ab41a2c97 Mon Sep 17 00:00:00 2001 From: Eric Dahl Date: Thu, 3 Dec 2026 01:40:06 -0500 Subject: [PATCH] X-Air test: count the mix-state queries instead of timing the read (ShowRecorder #1249) The test for a Mixer that ignores mix-state queries limited the read to 3 s of wall clock. Two of those seconds were its own timeouts (the USB routing and the first mix-state query, 1 s each), which left 1 s for about 40 loopback round trips; a busy CI runner took 4.22 s and 3.35 s with nothing wrong. What the test means is that the driver asks for mix state once and then stops. The fake records every query, so the test now checks that exactly one mix-state query was sent. The routing is answered, as in the other tests, and the reply timeout is the shared 3 s one, so a slow answer to a name is not mistaken for silence. Refs ericdahl-dev/ShowRecorder#1249 Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01VCgWWseQZtUzcSRzjqqQJQ --- Tests/MixerLinkTests/XAirDriverTests.swift | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Tests/MixerLinkTests/XAirDriverTests.swift b/Tests/MixerLinkTests/XAirDriverTests.swift index f59b15f..fd454db 100644 --- a/Tests/MixerLinkTests/XAirDriverTests.swift +++ b/Tests/MixerLinkTests/XAirDriverTests.swift @@ -102,18 +102,19 @@ struct XAirDriverTests { var state = FakeXAirMixer.State() state.channels[0] = .init(name: "Kick", color: 1) state.answersMixState = false + state.usbRouting = Self.defaultRouting // answered, so the only silence is the mix state (#462) let mixer = try await FakeXAirMixer(state) - // A 1 s timeout, so a loaded machine can still answer the names (#323); missing mix state still costs one - // timeout (under 3 s), not one per Source (18 s). - let driver = XAirDriver(endpoint: MixerEndpoint(host: "127.0.0.1", port: mixer.port), timeout: .seconds(1)) + // The one unanswered query waits out this timeout; every other query is answered, however busy the machine. + let driver = XAirDriver(endpoint: MixerEndpoint(host: "127.0.0.1", port: mixer.port), timeout: Loopback.mixedTimeout) - let clock = ContinuousClock() - var sources: [Source] = [] - let elapsed = try await clock.measure { sources = try await driver.sources(usbChannelCount: 18) } + let sources = try await driver.sources(usbChannelCount: 18) #expect(try #require(sources.first).name == "Kick") #expect(sources.allSatisfy { $0.isMuted == nil && $0.fader == nil && $0.inputSource == nil }) - #expect(elapsed < .seconds(3), "one timeout, not one per Source") + // Counted, not timed: a clock limit failed on a busy CI runner with nothing wrong (ShowRecorder #1249). Each + // unanswered query costs one timeout, so one mix-state query asked is one timeout, not one per Source. + let mixStateQueries = mixer.queries.filter { $0.contains("/mix/") || $0.hasSuffix("/config/insrc") } + #expect(mixStateQueries == ["/ch/01/mix/on"], "asked once, then skipped for the other 17 Sources") } @Test("An unexpected reply for mute, fader or input source leaves that value unknown, not the Link down")