Skip to content

test: bats suite for lib/audio-utils.sh + CI workflow - #23

Merged
JarbasAl merged 1 commit into
devfrom
feat/bats-tests
Jul 12, 2026
Merged

JarbasAl merged 1 commit into
devfrom
feat/bats-tests

Conversation

@JarbasAl

Copy link
Copy Markdown
Member

Summary

  • test/audio-utils.bats: 28 bats-core tests that source lib/audio-utils.sh with mocked commands (PATH-prepended stubs in test/stubs/, canned output in test/fixtures/):
    • aplay -l parsing: card lookup, USB picking (single / multiple-last-wins-with-warning / none)
    • fallback priority ordering, one test per tier: USB > HAT > headphones (bcm2835) > HDMI, plus the no-card error path
    • wpctl parsing: sink ID listing (incl. the * default marker), card-index→sink-ID mapping, node.name lookup incl. rc-1 miss
    • pactl parsing: card-index→sink-name mapping incl. "Card index not found", virtual-sink exclusion
    • udev env extraction (DEVPATH/DEVNAME/absent) and i2c_platform hint handling
    • detect_sound_server in a controlled PATH: running-server preference, install fallbacks, and the graceful no-server error path
  • .github/workflows/test.yml: runs bats test/ on ubuntu-latest (apt bats).

Injected-defect proof

Deliberately swapping the headphones/HDMI tiers inside select_fallback_card makes tests 8 ("headphones win when only onboard cards are present") and 9 ("HDMI is the last resort") fail; restoring the lib returns the suite to 28/28 green. The suite genuinely pins the priority order.

🤖 Generated with Claude Code

28 tests over the shared library using PATH-prepended command stubs
and canned aplay/wpctl/pactl fixtures: card-priority ordering
(USB > HAT > headphones > HDMI), USB card picking, wpctl/pactl sink
parsing and card-to-sink mapping, udev env var extraction,
i2c_platform hint handling and sound-server detection.
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@JarbasAl, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef9288ab-3b6d-4bf0-8b1a-2c2d7abb78b9

📥 Commits

Reviewing files that changed from the base of the PR and between 2c185fd and 6b4f686.

📒 Files selected for processing (16)
  • .github/workflows/test.yml
  • test/audio-utils.bats
  • test/fixtures/aplay_all_cards.txt
  • test/fixtures/aplay_hat_only.txt
  • test/fixtures/aplay_hdmi_only.txt
  • test/fixtures/aplay_none.txt
  • test/fixtures/aplay_onboard_only.txt
  • test/fixtures/aplay_two_usb.txt
  • test/fixtures/pactl_list_sinks.txt
  • test/fixtures/pactl_short_sinks.txt
  • test/fixtures/wpctl_inspect_50.txt
  • test/fixtures/wpctl_inspect_55.txt
  • test/fixtures/wpctl_status.txt
  • test/stubs/aplay
  • test/stubs/pactl
  • test/stubs/wpctl
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/bats-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JarbasAl
JarbasAl merged commit 883ff6d into dev Jul 12, 2026
3 checks passed
@JarbasAl
JarbasAl deleted the feat/bats-tests branch July 12, 2026 15:19
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