chore(tests): drop a write-timeout assertion that the line above already decides - #652
Merged
Merged
Conversation
…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>
Contributor
Author
|
/agentic_review |
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can switch off images and animations for a plain-text comment |
PR Summary by QodoRemove redundant SerialPort write-timeout assertion in SerialStreamTransport tests
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Contributor
Author
|
Qodo-clean, CI green — ready for review. Shepherd verification (independent of the opening agent)
|
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.
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_BoundsBothDirectionschecked the serial write timeout twice. It first pinned it to exactly2000, then asserted it was notSerialPort.InfiniteTimeout.InfiniteTimeoutis 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. TheReadTimeoutassertion 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
WriteTimeoutkeeping the 30-second connect timeout for the life of the port, not it going infinite. The test arranges exactly that scenario (WriteTimeout = 30000) andAssert.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.Nlock): net9.0 3827 passed / 0 failed / 2 skipped, net10.0 3827 passed / 0 failed / 2 skipped, plusDaqifi.Mcp.Tests217 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.