Skip to content

chore(tests): drop a write-timeout assertion that the line above already decides - #652

Merged
tylerkron merged 1 commit into
mainfrom
chore/prune-unfailable-write-timeout-assertion
Aug 24, 2026
Merged

tylerkron merged 1 commit into
mainfrom
chore/prune-unfailable-write-timeout-assertion

Conversation

@tylerkron

Copy link
Copy Markdown
Contributor

Produced by the useless-test-pruner maintenance routine, which looks for tests asserting something that structurally cannot fail. This one is a single deleted line, and it is safe because the assertion it removes was already decided by the assertion immediately above it.

What was wrong

SerialStreamTransport_ApplyOperationalTimeouts_BoundsBothDirections checked the serial write timeout twice. It first pinned it to exactly 2000, then asserted it was not SerialPort.InfiniteTimeout. InfiniteTimeout is the compile-time constant -1, so by the time the second assertion runs, the first one has already established the value is 2000 — the "not infinite" check can never be the thing that fails. It reads like a second, independent guarantee about the write path being bounded, but it contributes nothing, and that is worse than not being there at all: it makes the test look like it covers more than it does.

How it was fixed

Deleted that one line. Assert.Equal(2000, port.WriteTimeout) directly above is untouched and is what actually covers the behavior — it is strictly stronger, since pinning the exact value rules out infinity along with every other wrong value. The ReadTimeout assertion and the explanatory comment above the test are also untouched.

The one thing a reviewer might reasonably push back on is whether the deleted line documented the intent of #399. I do not think it did: the regression #399 describes is WriteTimeout keeping the 30-second connect timeout for the life of the port, not it going infinite. The test arranges exactly that scenario (WriteTimeout = 30000) and Assert.Equal(2000, ...) is the assertion that catches it. The prose comment above the test already states the "both directions must end up bounded and short" intent for a future reader.

Verification

Build clean, 0 warnings. Full suite green on both target frameworks (run under a tests.N lock): net9.0 3827 passed / 0 failed / 2 skipped, net10.0 3827 passed / 0 failed / 2 skipped, plus Daqifi.Mcp.Tests 217 passed. Coverage is unchanged — the removed line exercised no production code the surviving assertion does not.

Bench validation does not apply here: this is a test-only change that touches no production code and needs no device, so the board was never used.

Not merging — for review.

…ady decides

SerialStreamTransport_ApplyOperationalTimeouts_BoundsBothDirections pinned
WriteTimeout to exactly 2000 and then asserted it was not
SerialPort.InfiniteTimeout. InfiniteTimeout is the compile-time constant -1,
so once the exact-value assertion above has passed, the second one cannot
fail — it reads as a second guarantee while checking nothing.

The #399 regression it appears to guard is WriteTimeout retaining the 30 s
connect timeout, not going infinite; the test arranges 30000 and
Assert.Equal(2000, ...) is what actually catches that.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tylerkron
tylerkron requested a review from a team as a code owner August 24, 2026 16:24
@tylerkron

Copy link
Copy Markdown
Contributor Author

/agentic_review

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can switch off images and animations for a plain-text comment

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Remove redundant SerialPort write-timeout assertion in SerialStreamTransport tests

🧪 Tests 🕐 Less than 10 minutes

Grey Divider

AI Description

• Remove an unfailable write-timeout assertion from SerialStreamTransport timeout test.
• Keep exact-value timeout assertions that already cover the bounded-write guarantee.
Diagram

graph TD
  T["SerialStreamTransportTests"] --> A["Timeout assertions"] --> P["SerialPort timeouts"]

  subgraph Legend
    direction LR
    _test["Test"] ~~~ _logic["Assertion logic"] ~~~ _ext{{"System API"}}
  end
Loading
High-Level Assessment

Current approach is optimal: removing a redundant assertion reduces noise while preserving the stronger exact-value check that already excludes infinite/incorrect timeouts.

Files changed (1) +0 / -1

Tests (1) +0 / -1
SerialStreamTransportTests.csDrop redundant WriteTimeout != InfiniteTimeout assertion +0/-1

Drop redundant WriteTimeout != InfiniteTimeout assertion

• Removes an unfailable assertion that WriteTimeout is not SerialPort.InfiniteTimeout. The preceding exact-value assertion (WriteTimeout == 2000) already guarantees this, so test intent remains unchanged with less redundancy.

src/Daqifi.Core.Tests/Communication/Transport/SerialStreamTransportTests.cs

@tylerkron

Copy link
Copy Markdown
Contributor Author

Qodo-clean, CI green — ready for review.

Shepherd verification (independent of the opening agent)

@tylerkron
tylerkron added this pull request to the merge queue Aug 24, 2026
Merged via the queue into main with commit 6e0b105 Aug 24, 2026
1 check passed
@tylerkron
tylerkron deleted the chore/prune-unfailable-write-timeout-assertion branch August 24, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant