Skip to content

test(channels): close the framework's uncovered lines and record the rest - #781

Merged
huichen merged 1 commit into
mainfrom
test/chan-residual-coverage
Sep 22, 2026
Merged

huichen merged 1 commit into
mainfrom
test/chan-residual-coverage

Conversation

@huichen

@huichen huichen commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

test(channels): close the framework's uncovered lines and record the rest

Per-line coverage (llvm-cov DA:<line>,0) of the channel framework, on top of
the twelve providers. Two arms turned out to be dead by construction and were
deleted rather than exempted, one guard was made testable, and five tests close
behaviours that were previously only exercised by accident.

Removed:

  • slack::parse_event and mattermost::parse_posted returned
    Result<Option<Inbound>> while having no error path at all, so every caller
    carried an unreachable Err arm. They return Option<Inbound> now, and
    clippy's question_mark hint folded a let ... else into ?.
  • evict_idle had a None => return that the capacity guard above it makes
    impossible (the guard leaves at least one conversation other than keep), and
    its tail read as an unbounded loop with a second exit. It is now a while
    bounded by the table size, with the invariant stated where it is relied on.

Made testable:

  • start_all decides each registered channel in entry_action, which takes a
    definition instead of reaching into the registry. That is what lets
    "enabled but not built is reported, not silently skipped" be covered: no
    planned channel ships in this build, so the test constructs one.

New tests:

  • an unreadable channel config no longer hides a prompt: the attachment fetch
    fails, the message is still handed to the bridge and acknowledged;
  • the Events API webhook test now waits for the dispatched event's
    acknowledgement
    instead of sleeping 300ms and asserting nothing — the
    previous assertion claimed a denied event, but the message was in fact
    dropped as backpressure and never reached the pipeline;
  • a supervisor loop with a wedged data directory reports the provider failure
    and still stops cleanly when asked (the existing test never polled the task,
    which is why the warning was uncovered);
  • a read error ends pump_lines instead of retrying it.

Also verified by experiment (and recorded): a server that drops a websocket
without a close frame does not end the stream — the client reports
ResetWithoutClosingHandshake on the read arm — so the None arm of both
session loops cannot be reached through this client.

docs/architecture/channels-test-coverage.md (+ zh-CN) states the rule and
lists the 22 lines that remain uncovered, grouped as environmental,
unreachable-by-construction, or attribution artifact, each with the reason or
the test that proves the code runs.

…rest

Per-line coverage (llvm-cov `DA:<line>,0`) of the channel framework, on top of
the twelve providers. Two arms turned out to be dead by construction and were
deleted rather than exempted, one guard was made testable, and five tests close
behaviours that were previously only exercised by accident.

Removed:
- `slack::parse_event` and `mattermost::parse_posted` returned
  `Result<Option<Inbound>>` while having no error path at all, so every caller
  carried an unreachable `Err` arm. They return `Option<Inbound>` now, and
  clippy's `question_mark` hint folded a `let ... else` into `?`.
- `evict_idle` had a `None => return` that the capacity guard above it makes
  impossible (the guard leaves at least one conversation other than `keep`), and
  its tail read as an unbounded loop with a second exit. It is now a `while`
  bounded by the table size, with the invariant stated where it is relied on.

Made testable:
- `start_all` decides each registered channel in `entry_action`, which takes a
  definition instead of reaching into the registry. That is what lets
  "enabled but not built is reported, not silently skipped" be covered: no
  planned channel ships in this build, so the test constructs one.

New tests:
- an unreadable channel config no longer hides a prompt: the attachment fetch
  fails, the message is still handed to the bridge and acknowledged;
- the Events API webhook test now *waits for the dispatched event's
  acknowledgement* instead of sleeping 300ms and asserting nothing — the
  previous assertion claimed a denied event, but the message was in fact
  dropped as backpressure and never reached the pipeline;
- a supervisor loop with a wedged data directory reports the provider failure
  and still stops cleanly when asked (the existing test never polled the task,
  which is why the warning was uncovered);
- a read error ends `pump_lines` instead of retrying it.

Also verified by experiment (and recorded): a server that drops a websocket
without a close frame does not end the stream — the client reports
`ResetWithoutClosingHandshake` on the read arm — so the `None` arm of both
session loops cannot be reached through this client.

`docs/architecture/channels-test-coverage.md` (+ zh-CN) states the rule and
lists the 22 lines that remain uncovered, grouped as environmental,
unreachable-by-construction, or attribution artifact, each with the reason or
the test that proves the code runs.
@huichen
huichen enabled auto-merge (squash) September 22, 2026 16:05
@huichen
huichen merged commit a4b9347 into main Sep 22, 2026
12 checks passed
@huichen
huichen deleted the test/chan-residual-coverage branch September 22, 2026 16:11
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