Skip to content

Add tests that can run in CI, and split up the CI workflows - #67

Merged
HEnquist merged 8 commits into
masterfrom
ci-device-tests
Oct 2, 2026
Merged

HEnquist merged 8 commits into
masterfrom
ci-device-tests

Conversation

@HEnquist

@HEnquist HEnquist commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Closes #66. Adds a device backed test suite that runs on VB-Cable installed on the
runner, plus a set of device free tests, and splits the single workflow into three.

  • ci.yml for the device free checks, device-tests.yml for the suite that needs a
    device, publish.yml for releases. A flaky device job can no longer block the lint
    and unit test signal.
  • 30 device tests behind a new device-tests feature, so a plain cargo test neither
    builds nor runs them. Playback and capture in both sharing modes and both timing
    modes, the exclusive mode capability probe cross checked against what
    initialize_client really accepts, the declared data ranges, enumeration, and the
    buffer length and direction guards.
  • 6 device free tests for the arithmetic the crate does itself, which had none:
    periods, buffer flags, hardware support bits and channel masks.
  • The doctests now run in CI, which they never did, since --all-targets excludes
    them. cargo doc runs with -D warnings too.
  • VB-Cable is installed through SetupAPI, no devcon and no reboot, ported from the
    CamillaDSP e2e suite. The download is pinned and its hash checked.
  • Fixed a stale claim in the process loopback docs that the tests caught:
    get_sharemode does work in that mode.

The list of methods that do not work in process loopback mode claimed that
`get_sharemode` always returns `None`. It returns the right value, since
`initialize_client` records the sharing mode on the Rust side rather than asking
the client for it. Removed that entry, and noted that `is_aec_supported` needs an
initialised client, which is not obvious and is not written down anywhere else.

The example is now `no_run`. It activates a process loopback client, so it needs a
running audio service, which a build machine may not have. That also lets the
doctests run in CI, which they previously did not.
Replaces windows-ci.yml with ci.yml for the device free checks and publish.yml for
releases. Keeping them apart means the publish job no longer needs an event guard,
and a device job can be added without a flaky device blocking the lint and unit test
signal.

- Run the doctests. `cargo test --all-targets` excludes them, so none of the three
  had ever run.
- Run `cargo doc` with `-D warnings`, which nothing checked before.
- Pass `--all-features` to check and clippy, so everything is linted.
- Add dependency caching, a concurrency group, a permissions block, timeouts and
  workflow_dispatch.
- Drop `cargo check --examples`, which `--all-targets` already covers.
Six tests in tests/public_api.rs, covering the arithmetic the crate does itself and
which had no tests at all: `calculate_period_100ns`, `BufferFlags`, `HardwareSupport`,
`make_channelmasks` beyond the three channel case its doctest covers, and the option
accumulation in `AudioClientProperties`.

Also covers the enumerator on a machine with no audio device, which only a bare CI
runner can exercise. That part is behind WASAPI_EXPECT_NO_DEVICES, so the test is
harmless on a machine that has devices, and ci.yml sets it.
Thirty tests in tests/device/, behind the new `device-tests` feature so a plain
`cargo test` neither builds nor runs them. The CI job installs VB-Cable on the runner
through SetupAPI, with no devcon and no reboot, ported from the CamillaDSP e2e suite.

- Playback and capture in both sharing modes and both timing modes. The assertion is
  that the library asks for and delivers data at the rate the format declares, so the
  data written is silence and nothing looks at content.
- The exclusive mode capability probe and `is_supported` cross checked against what
  `initialize_client` really accepts, over a matrix of formats, rates and channel
  counts.
- The data ranges a driver declares, which until now had only its reply parsing
  tested, not the topology walk or the IOCTL.
- Enumeration, the buffer length checks, and the direction guards.

The tests look for the cable by its interface name, which is the same whether it was
installed by the vendor setup or by the driver alone. A missing cable prints a note
and passes, unless WASAPI_REQUIRE_DEVICE is set, which the CI job does so a failed
install cannot look green.
The licence in the archive readme allows copying the package as is, so the earlier
note claiming redistribution needs an agreement was wrong. Replaced it with the
origin and donationware credit the licence asks for on distribution, and with the
clause that does apply here: integrating the package into another installation
procedure needs the author's agreement, and this script installs the driver itself
rather than running the vendor setup.
@HEnquist
HEnquist marked this pull request as ready for review October 2, 2026 07:04
@HEnquist
HEnquist requested a balanced review from Copilot October 2, 2026 07:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Some assertions can miss format and channel regressions, and the advertised device-test logging option is nonfunctional.

Review effort: Balanced
Findings: 4 Medium severity · 2 Low severity

Open (6)
What changed in this PR

Adds device-free and VB-Cable-backed test coverage while separating CI, device testing, and publishing workflows.

Changes:

  • Adds public API and device-backed integration tests.
  • Splits CI, device testing, and publishing workflows.
  • Adds secure VB-Cable installation and updates documentation.
File Description
tests/​public_api.rs Adds device-free API tests.
tests/​device/​support.rs Provides shared device-test infrastructure.
tests/​device/​streams.rs Tests playback and capture mechanics.
tests/​device/​main.rs Defines the gated device-test target.
tests/​device/​errors.rs Exercises device-related error paths.
tests/​device/​enumeration.rs Tests endpoint enumeration and lookup.
tests/​device/​capability.rs Tests formats, probes, and data ranges.
src/​api.rs Corrects process-loopback documentation.
README.md Documents test-suite usage.
Cargo.toml Adds the device-test feature and target.
.github/​workflows/​windows-ci.yml Removes the combined legacy workflow.
.github/​workflows/​publish.yml Adds a dedicated publishing workflow.
.github/​workflows/​device-tests.yml Adds VB-Cable-backed CI testing.
.github/​workflows/​ci.yml Adds device-free checks and tests.
.github/​scripts/​install_vbcable.ps1 Installs the pinned VB-Cable driver.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/device-tests.yml Resolved
Comment thread tests/device/capability.rs Resolved
Comment thread tests/device/capability.rs Resolved
Comment thread tests/device/support.rs Resolved
Comment thread Cargo.toml Resolved
Comment thread tests/device/support.rs Resolved
Four real defects and two stale comments.

- The fixture held the device lock in its first field, so it was released before the
  devices it covers, since fields drop in declaration order. Moved it last, which is
  the whole point of the lock: the endpoint is not free until the devices are dropped.
- `probe_matches_is_supported` keyed formats on the two bit depths only, so S32 and
  F32 both collapsed to (32, 32). If the probe reported one and dropped the other,
  the check for formats it left out skipped both and the regression passed. The key
  now includes the sample type.
- WASAPI_TEST_LOG was read by nothing, so the log level input in the device workflow
  did nothing at all. The fixture now initialises simplelog from it.
- `multichannel_endpoint_declares_more_channels` never compared the two endpoints,
  and could not have: both render endpoints of the cable declare 16 channels and both
  accept up to 16, so the premise in its name was wrong. Replaced with a test of what
  is actually worth checking, that a 16 channel format negotiates a mask from
  `make_channelmasks`, where above 8 channels only the simple mask is left. That also
  made the 16 channel endpoint lookup unused, so it is gone.
- Corrected the feature comment, which pointed at tests/device.rs rather than the
  directory, and a comment in `init_com` that referred to a COM lifecycle test which
  no longer exists.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Manual publishing bypasses the release gate, and several new assertions can miss the regressions they claim to cover.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (6)
Previously missed (3)

In code that hasn't changed since last review

Medium severity Comparison omits sample type and conflates S32 with F32

tests/​device/​capability.rs:421

This comparison drops the sample type, so S32 and F32 both become the same (channels, 32, 32) entry. A bounded scan returning one while the staged scan returns the other would therefore pass; include get_subformat() (or an orderable encoding of it) in the comparison key.

Medium severity Test does not verify documented post-initialization limitations

tests/​device/​errors.rs:360

The documented limitations are not actually verified after initialization: get_available_space_in_frames is currently called only before initialization, when any normal client returns ClientNotInit, and the render-client, session-control, and clock failures are never checked. Assert these calls here after initialization so the test can detect a stale process-loopback limitation.

Medium severity Assertion fails to verify option accumulation

tests/​public_api.rs:187

This assertion does not prove that options accumulate: if set_option were changed to assign its argument, raw would still differ from both (which would contain only MatchFormat) and the test would pass. Compare both with each single-option value so replacement of the first option is detected.

Comment thread .github/workflows/publish.yml Resolved
workflow_dispatch let anyone with write access publish any branch or tag to
crates.io with the registry token, which the old single workflow did not allow: it
gated publishing on a published release. A crates.io release cannot be taken back,
so the gate is worth keeping tight.

Nothing is lost. A release whose publish failed can be retried with "Re-run jobs",
which replays the run with the same release event. The CI and device workflows keep
their manual trigger, where it is useful and harmless.
@HEnquist
HEnquist merged commit c539942 into master Oct 2, 2026
3 checks passed
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.

Add tests that can run in CI

2 participants