Repository navigation
fix(cli): stop pacquet bugs tests from opening the developer's browser - #12926
Conversation
The bugs happy-path integration tests spawned the real binary, whose open_url launched xdg-open unconditionally, so every test run opened https://github.com/test/pkg/issues (and friends) in the developer's browser. Thread the existing pacquet_network_web_auth::OpenUrl capability through BugsArgs::run, replacing the hand-rolled per-OS launcher with the shared Host provider (the open crate, as the web-auth flow already uses). Port the happy-path coverage to unit tests driving run through a recording OpenUrl fake — mirroring the mocked open module in the TypeScript tests — and keep only the error paths, which never reach the browser, as binary-level integration tests.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesBugs URL opening
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant BugsCommand
participant BugsArgs
participant OpenUrl
BugsCommand->>BugsArgs: run::<Host>(config, dir)
BugsArgs->>BugsArgs: resolve and sanitize bugs URL
BugsArgs->>OpenUrl: open_url::<Host>(url)
OpenUrl-->>BugsArgs: browser launch result
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
PR Summary by Qodofix(cli): stop
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1.
|
There was a problem hiding this comment.
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 `@pnpm/crates/cli/src/cli_args/bugs/tests.rs`:
- Around line 303-321: Reset the thread-local URL recording state when it is
read. Update the opened_urls function to retrieve the vector with take() instead
of borrowing and cloning OPENED_URLS, ensuring each test clears previously
recorded URLs even when threads are reused.
🪄 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.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0e782445-9f68-4d1c-b834-7ccfa6069910
📒 Files selected for processing (4)
pnpm/crates/cli/src/cli_args/bugs.rspnpm/crates/cli/src/cli_args/bugs/tests.rspnpm/crates/cli/src/cli_args/dispatch_query.rspnpm/crates/cli/tests/bugs.rs
PR Code Suggestions ✨Warning
Explore these optional code suggestions:
|
||||||||||||
Micro-Benchmark ResultsLinux |
Tests that libtest runs on the same thread (--test-threads=1) would otherwise observe URLs recorded by earlier tests through the shared thread-local.
|
Addressed the Qodo findings in aaee2e1:
Written by an agent (Claude Code, claude-fable-5). |
|
Code review by qodo was updated up to the latest commit aaee2e1 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12926 +/- ##
=======================================
Coverage 85.43% 85.44%
=======================================
Files 474 474
Lines 74546 74536 -10
=======================================
- Hits 63691 63684 -7
+ Misses 10855 10852 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Running the pacquet test suite opened
https://github.com/test/pkg/issues(and two other URLs) in the developer's browser — up to five tabs per run. Thepacquet bugshappy-path integration tests spawned the real binary, whoseopen_urllaunchedxdg-openunconditionally, with failures downgraded to a debug log so the tests stayed green while the browser filled up.This PR routes the browser launch through the existing
OpenUrldependency-injection seam and moves the happy-path coverage to unit tests that record the opened URL instead of launching a browser:BugsArgs::runandopen_urlare now generic overSys: OpenUrl, reusing the capability trait andHostprovider frompacquet-network-web-auth(promoted from dev-dependency to dependency; it was already in the production build graph viapacquet-auth-commands). The dispatch site turbofishesHost.bugs.rs(xdg-open/open/ShellExecuteW, including theunsafeWindows block) is deleted; production now launches viaopen::that_detached, the same path the web-auth login flow already uses.pnpm/crates/cli/tests/bugs.rsintobugs/tests.rsunit tests drivingrunthrough a thread-localRecordingBrowserfake — mirroring the mockedopenmodule in the TypeScript tests (pnpm11/deps/inspection/commands/test/bugs.ts), so the two stacks keep matching scenario coverage. The integration file keeps only the error paths, which never reach the browser, matching the conventiondocs.rsandrepo.rsalready follow.Verification:
xdg-openshim onPATHrecorded zero invocations across the whole bugs test set (previously five per run), while the same shim confirmed the real binary still opens the URL and prints it.Sys::open_url) made all seven new unit tests fail, so they catch regressions.cargo nextestfor the bugs tests, clippy with--deny warnings,cargo fmt, taplo, typos, and rustdoc are all clean.No TypeScript changes: there is no user-visible behavior change, and the TS tests already mock
open. No changeset: Rust-only change. Follow-up candidate (not in this PR, to keep it focused):docs.rsandrepo.rsstill carry their own duplicated per-OS launcher code and could migrate to the same seam.Note for reviewers: the full
pacquet-clisuite currently has one unrelated failure onmain(run_recursive::test_pattern_from_workspace_yaml_is_respected_by_the_test_script), a semantic conflict between #12914 and #12910 that pacquet CI never ran on combined (the subsequent pushes tomainwere path-filtered). It fails identically without this PR and will be addressed separately.Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.Written by an agent (Claude Code, claude-fable-5).
Summary by CodeRabbit
New Features
bugs/issuescommands to open the correct URL consistently across environments.Bug Fixes
bugsandrepositorymetadata, including registry responses.git+https://.../.gitURLs and scoped package names.Tests