Skip to content

refactor: use test-that for declarative assertion#300

Merged
kxxt merged 1 commit into
mainfrom
test-that
Jul 24, 2026
Merged

refactor: use test-that for declarative assertion#300
kxxt merged 1 commit into
mainfrom
test-that

Conversation

@kxxt

@kxxt kxxt commented Jul 24, 2026

Copy link
Copy Markdown
Owner

See https://hovinen.me/announcements/2026/06/24/introducing-test-that.html for the rationale.

Summary by CodeRabbit

  • Tests
    • Standardized test assertions across backend, core, exporter, TUI, and smoke suites using a matcher-based style (test-that).
    • Improved readability and failure diagnostics for errors, substrings, collections/optionals, and numeric thresholds.
    • Kept all test intent the same while making expectations more expressive (e.g., empty/non-empty, some/none, and range checks).
  • Chores
    • Added test-that as a workspace-managed development dependency and enabled it for relevant crates.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tracexec Ready Ready Preview, Comment Jul 24, 2026 2:04pm

@kxxt
kxxt marked this pull request as ready for review July 24, 2026 13:47
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0904898a-a047-4f27-b9fc-288ffc94d24f

📥 Commits

Reviewing files that changed from the base of the PR and between 131a043 and 61447cb.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (43)
  • Cargo.toml
  • crates/tracexec-backend-ebpf/Cargo.toml
  • crates/tracexec-backend-ebpf/src/bin/verifier_complexity.rs
  • crates/tracexec-backend-ebpf/src/event.rs
  • crates/tracexec-backend-ebpf/src/process_tracker.rs
  • crates/tracexec-backend-ebpf/src/tracer.rs
  • crates/tracexec-backend-ebpf/tests/exec_events.rs
  • crates/tracexec-backend-ptrace/Cargo.toml
  • crates/tracexec-backend-ptrace/src/ptrace/tracer/inner.rs
  • crates/tracexec-backend-ptrace/src/ptrace/tracer/test.rs
  • crates/tracexec-core/Cargo.toml
  • crates/tracexec-core/src/account.rs
  • crates/tracexec-core/src/breakpoint.rs
  • crates/tracexec-core/src/cli.rs
  • crates/tracexec-core/src/cli/args.rs
  • crates/tracexec-core/src/cli/config.rs
  • crates/tracexec-core/src/cmdbuilder.rs
  • crates/tracexec-core/src/event.rs
  • crates/tracexec-core/src/event/id.rs
  • crates/tracexec-core/src/event/message.rs
  • crates/tracexec-core/src/event/parent.rs
  • crates/tracexec-core/src/primitives/local_chan.rs
  • crates/tracexec-core/src/printer.rs
  • crates/tracexec-core/src/proc.rs
  • crates/tracexec-core/src/pty.rs
  • crates/tracexec-core/src/timestamp.rs
  • crates/tracexec-core/src/tracer.rs
  • crates/tracexec-exporter-json/Cargo.toml
  • crates/tracexec-exporter-json/src/lib.rs
  • crates/tracexec-exporter-perfetto/Cargo.toml
  • crates/tracexec-exporter-perfetto/src/packet.rs
  • crates/tracexec-exporter-perfetto/src/perfetto.rs
  • crates/tracexec-exporter-perfetto/src/producer.rs
  • crates/tracexec-exporter-perfetto/src/recorder.rs
  • crates/tracexec-tui/Cargo.toml
  • crates/tracexec-tui/src/app.rs
  • crates/tracexec-tui/src/breakpoint_manager.rs
  • crates/tracexec-tui/src/details_popup.rs
  • crates/tracexec-tui/src/event.rs
  • crates/tracexec-tui/src/hit_manager.rs
  • crates/tracexec-tui/src/query.rs
  • crates/tracexec-tui/src/theme.rs
  • tests/smoke.rs
🚧 Files skipped from review as they are similar to previous changes (36)
  • crates/tracexec-exporter-perfetto/Cargo.toml
  • Cargo.toml
  • crates/tracexec-exporter-perfetto/src/recorder.rs
  • crates/tracexec-core/src/event/message.rs
  • crates/tracexec-core/src/event/id.rs
  • crates/tracexec-tui/src/theme.rs
  • crates/tracexec-core/src/account.rs
  • tests/smoke.rs
  • crates/tracexec-exporter-perfetto/src/perfetto.rs
  • crates/tracexec-core/Cargo.toml
  • crates/tracexec-core/src/event/parent.rs
  • crates/tracexec-backend-ebpf/src/event.rs
  • crates/tracexec-backend-ebpf/src/process_tracker.rs
  • crates/tracexec-tui/src/breakpoint_manager.rs
  • crates/tracexec-core/src/cli.rs
  • crates/tracexec-backend-ptrace/Cargo.toml
  • crates/tracexec-tui/Cargo.toml
  • crates/tracexec-core/src/pty.rs
  • crates/tracexec-backend-ptrace/src/ptrace/tracer/test.rs
  • crates/tracexec-core/src/breakpoint.rs
  • crates/tracexec-exporter-perfetto/src/producer.rs
  • crates/tracexec-tui/src/event.rs
  • crates/tracexec-tui/src/hit_manager.rs
  • crates/tracexec-exporter-perfetto/src/packet.rs
  • crates/tracexec-core/src/cmdbuilder.rs
  • crates/tracexec-core/src/printer.rs
  • crates/tracexec-backend-ptrace/src/ptrace/tracer/inner.rs
  • crates/tracexec-backend-ebpf/src/bin/verifier_complexity.rs
  • crates/tracexec-core/src/primitives/local_chan.rs
  • crates/tracexec-core/src/event.rs
  • crates/tracexec-core/src/proc.rs
  • crates/tracexec-backend-ebpf/Cargo.toml
  • crates/tracexec-core/src/cli/config.rs
  • crates/tracexec-core/src/timestamp.rs
  • crates/tracexec-backend-ebpf/src/tracer.rs
  • crates/tracexec-backend-ebpf/tests/exec_events.rs

Walkthrough

Adds test-that as a workspace-managed development dependency and migrates assertions across backend, core, exporter, TUI, and smoke tests to matcher-based forms. Production logic and public APIs remain unchanged.

Changes

Test assertion migration

Layer / File(s) Summary
Workspace dependency setup
Cargo.toml, crates/*/Cargo.toml
Adds the workspace test-that dependency and enables it for affected crates.
Backend test assertions
crates/tracexec-backend-ebpf/..., crates/tracexec-backend-ptrace/...
Replaces direct boolean, option, result, collection, and substring checks with test-that matchers.
Core test assertions
crates/tracexec-core/src/...
Migrates assertions covering parsing, formatting, channels, printing, process data, PTY behavior, timestamps, and tracer state.
Exporter test assertions
crates/tracexec-exporter-json/..., crates/tracexec-exporter-perfetto/...
Uses matchers for generated output, packet content, annotations, and recorder state.
TUI and smoke-test assertions
crates/tracexec-tui/src/..., tests/smoke.rs
Migrates UI rendering, event, breakpoint, hit, query, theme, and smoke-test assertions.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: refactoring tests to use test-that declarative assertions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test-that

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/tracexec-backend-ebpf/src/tracer.rs`:
- Around line 1527-1529: Fix the assertions around the html and lcov values so
each assert_that! first argument is a string expression compatible with
contains_substring(...), rather than combining bool and String values with || or
&&. Keep any alternative-condition logic outside the matcher, using separate
valid assertions or an appropriate matcher composition.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9fa6c5f2-bae3-46b5-898b-5dc1c4265e96

📥 Commits

Reviewing files that changed from the base of the PR and between fc73331 and 131a043.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (43)
  • Cargo.toml
  • crates/tracexec-backend-ebpf/Cargo.toml
  • crates/tracexec-backend-ebpf/src/bin/verifier_complexity.rs
  • crates/tracexec-backend-ebpf/src/event.rs
  • crates/tracexec-backend-ebpf/src/process_tracker.rs
  • crates/tracexec-backend-ebpf/src/tracer.rs
  • crates/tracexec-backend-ebpf/tests/exec_events.rs
  • crates/tracexec-backend-ptrace/Cargo.toml
  • crates/tracexec-backend-ptrace/src/ptrace/tracer/inner.rs
  • crates/tracexec-backend-ptrace/src/ptrace/tracer/test.rs
  • crates/tracexec-core/Cargo.toml
  • crates/tracexec-core/src/account.rs
  • crates/tracexec-core/src/breakpoint.rs
  • crates/tracexec-core/src/cli.rs
  • crates/tracexec-core/src/cli/args.rs
  • crates/tracexec-core/src/cli/config.rs
  • crates/tracexec-core/src/cmdbuilder.rs
  • crates/tracexec-core/src/event.rs
  • crates/tracexec-core/src/event/id.rs
  • crates/tracexec-core/src/event/message.rs
  • crates/tracexec-core/src/event/parent.rs
  • crates/tracexec-core/src/primitives/local_chan.rs
  • crates/tracexec-core/src/printer.rs
  • crates/tracexec-core/src/proc.rs
  • crates/tracexec-core/src/pty.rs
  • crates/tracexec-core/src/timestamp.rs
  • crates/tracexec-core/src/tracer.rs
  • crates/tracexec-exporter-json/Cargo.toml
  • crates/tracexec-exporter-json/src/lib.rs
  • crates/tracexec-exporter-perfetto/Cargo.toml
  • crates/tracexec-exporter-perfetto/src/packet.rs
  • crates/tracexec-exporter-perfetto/src/perfetto.rs
  • crates/tracexec-exporter-perfetto/src/producer.rs
  • crates/tracexec-exporter-perfetto/src/recorder.rs
  • crates/tracexec-tui/Cargo.toml
  • crates/tracexec-tui/src/app.rs
  • crates/tracexec-tui/src/breakpoint_manager.rs
  • crates/tracexec-tui/src/details_popup.rs
  • crates/tracexec-tui/src/event.rs
  • crates/tracexec-tui/src/hit_manager.rs
  • crates/tracexec-tui/src/query.rs
  • crates/tracexec-tui/src/theme.rs
  • tests/smoke.rs

Comment thread crates/tracexec-backend-ebpf/src/tracer.rs Outdated
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.19%. Comparing base (04c54fb) to head (61447cb).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #300      +/-   ##
==========================================
- Coverage   82.21%   82.19%   -0.02%     
==========================================
  Files          84       84              
  Lines       21057    21062       +5     
==========================================
  Hits        17311    17311              
- Misses       3746     3751       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kxxt
kxxt merged commit 6383157 into main Jul 24, 2026
25 checks passed
@kxxt
kxxt deleted the test-that branch July 24, 2026 14:18
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