Skip to content

refactor(pacquet/network-web-auth/test): argument-gate web_auth_fake! helpers - #13277

Merged
zkochan merged 7 commits into
mainfrom
claude/test-fake-macro-arg-docs-ciq394
Aug 1, 2026
Merged

zkochan merged 7 commits into
mainfrom
claude/test-fake-macro-arg-docs-ciq394

Conversation

@KSXGitHub

@KSXGitHub KSXGitHub commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

web_auth_fake! — the shared OTP / web-auth test fake in crates/network-web-auth-testing — emitted its whole surface (FakeHost with its eight capability impls, both reporters, every set_* setter, and the message queries) into every test and silenced the unused parts with #[allow(dead_code)]. That blanket suppression is noise and can mask a genuinely dead helper.

This PR keeps only the thread_local! statics and reset() as the always-present core and gates each optional helper (FakeHost, RecordingReporter, UnexpectedReporter, the set_* setters, infos, warns) behind a named macro argument, with a catch-all compile_error! arm that rejects a mistyped name. Each test names exactly the helpers it drives, so nothing is unused and no #[allow(dead_code)] is needed. Call sites in network-web-auth, auth-commands, cli, and publish are updated accordingly. pnpm/CODE_STYLE_GUIDE.md documents the convention (new "Sharing a stateful fake across many tests" subsection), with login_fake! as the reference implementation.

Pacquet-only test-infrastructure and guide change with no user-visible CLI surface, so it needs no TypeScript counterpart and no changeset.

Squash Commit Body

web_auth_fake! emitted its whole surface — FakeHost with its eight capability
impls, both reporters, every set_* setter, and the message queries — into every
test and silenced the unused ones with allow(dead_code), noise that can also
mask a genuinely dead helper.

Keep only the thread-local statics and reset() as the always-present core and
generate each optional helper from a named macro argument, with a catch-all
compile_error! arm for a mistyped name. Each test names exactly the helpers it
drives, so nothing is unused and no dead_code allow is needed. Call sites in
network-web-auth, auth-commands, cli, and publish name their helpers, and
CODE_STYLE_GUIDE.md documents the convention with login_fake! as the reference.

Pacquet-only test-infrastructure and guide change; no user-visible surface, no
TypeScript counterpart, and no changeset.

Checklist

  • Implemented in both the TypeScript CLI and the Rust pnpm/ port, or notes what still needs porting. — Pacquet-only test-infrastructure and guide change; no TypeScript-CLI counterpart applies.
  • Added a changeset if this PR changes any published package. — N/A: test code and documentation only.
  • Added or updated tests. — Refactors the shared web_auth_fake! fake and its call sites; the affected suites (network-web-auth, auth-commands, cli, publish) pass locally.
  • Updated the documentation if needed. — Adds the CODE_STYLE_GUIDE.md subsection.

Summary by CodeRabbit

  • Tests

    • Improved authentication test coverage with configurable fake hosts, reporters, network behavior, terminal state, input, and timing.
    • Added clearer isolation and reset behavior between test scenarios.
    • Preserved existing coverage for OTP handling, web authentication, retries, fallbacks, timeouts, and error responses.
  • Documentation

    • Added guidance for creating and sharing stateful test fakes.
    • Documented available fake helpers and validation for unsupported options.

Summary by CodeRabbit

  • Tests

    • Improved authentication test coverage with configurable fake hosts, reporters, input, network, timing, and terminal behavior.
    • Added explicit state reset between scenarios for more reliable test isolation.
    • Preserved coverage for OTP handling, web authentication, retries, fallbacks, timeouts, and error cases.
  • Documentation

    • Added guidance for creating reusable, stateful test fakes and configuring optional helpers.
    • Documented validation for unsupported helper names.

When a shared test fake is expanded by a module-local `macro_rules!`, gate
each optional helper behind a named macro argument instead of emitting the
whole helper surface and blanket-suppressing the unused helpers with
`#[allow(dead_code)]`. That suppression is noise and can mask a genuinely
dead helper.

Add a "Sharing a stateful fake across many tests" subsection to
pnpm/CODE_STYLE_GUIDE.md's "Dependency injection for tests" section, next
to principle 3 (which the technique builds on). It documents the
argument-gating pattern, names `login_fake!` in
crates/auth-commands/src/login/support.rs as the reference implementation,
and covers the catch-all `(@Helper $unknown)` `compile_error!` arm that
turns a mistyped helper name into a clear diagnostic.

Resolves #13266.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JFCqwcs8qV7KqXqSyNvu3V
@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c59cb4b8-b89f-442e-96b5-94acf537d0fa

📥 Commits

Reviewing files that changed from the base of the PR and between 0990ca1 and 2b3f53f.

📒 Files selected for processing (1)
  • pnpm/CODE_STYLE_GUIDE.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • pnpm/CODE_STYLE_GUIDE.md

📝 Walkthrough

Walkthrough

The web_auth_fake! macro now generates only requested helpers while always providing core state and reset logic. Login, web-auth, OTP, CLI, and publish tests now invoke the macro with explicit helper lists.

Changes

Web-auth fake helper generation

Layer / File(s) Summary
Selective helper macro contract
pnpm/CODE_STYLE_GUIDE.md, pnpm/crates/network-web-auth-testing/src/lib.rs
The macro supports named helpers, always generates state and reset logic, and emits compile_error! for unknown helpers.
Login test fixture migration
pnpm/crates/auth-commands/src/login/*, pnpm/crates/cli/src/cli_args/login/tests.rs
Login tests now request the fake host, reporter, setters, and message queries required by each scenario.
Integration test fixture migration
pnpm/crates/network-web-auth/tests/with_otp_handling.rs, pnpm/crates/publish/src/publish_packed_pkg/tests.rs
OTP, web-auth, and publish tests now configure required helpers explicitly and reset fake state where needed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • pnpm/pnpm#13266: The changes implement and document the named-helper test-fake macro pattern described by the issue.

Possibly related PRs

  • pnpm/pnpm#13256: Refactors shared Rust test fakes with selectively generated helpers.
  • pnpm/pnpm#13479: Modifies non-interactive login tests and related web_auth_fake! configuration.

Suggested labels: product: pacquet

Suggested reviewers: zkochan, copilot

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/test-fake-macro-arg-docs-ciq394

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.

@KSXGitHub KSXGitHub changed the title docs(guide/dev): document the test-fake macro-argument technique docs(guide/dev): test-fake macro-argument Jul 24, 2026
claude added 3 commits July 24, 2026 23:31
Reusing a DI fake across tests is optional, so the note no longer reads as
if hoisting fakes into a module-local macro were the default. Make the
anti-dead_code rule conditional: it applies only when a fake is shared
across a module and carries helpers that not every test drives. In that
case, declare each optional helper's existence through a named macro
argument instead of emitting them all and silencing the unused ones with
an allow(dead_code).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JFCqwcs8qV7KqXqSyNvu3V
A style guide is a living document; a merged PR is a frozen point-in-time
artifact, and the repo's comment conventions keep refactor history in git
log/blame rather than in the source. The cited macros (poll_fake!,
browser_fake!, and the rest) are living code a reader can find by name, so
name them directly instead of pointing at a PR that only bit-rots.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JFCqwcs8qV7KqXqSyNvu3V
web_auth_fake! emitted its entire fake surface — FakeHost with its eight
capability impls, both reporters, every set_* setter, and the message
queries — into every test and blanket-suppressed the unused ones with
allow(dead_code). That suppression is noise and can mask a genuinely dead
helper, the anti-pattern the 'Sharing a stateful fake across many tests'
note in CODE_STYLE_GUIDE.md now forbids.

Emit only the thread-local statics and reset() as the always-present core,
and generate each optional helper from a named macro argument, with a
catch-all compile_error! arm that rejects a mistyped helper name. Every
test now names exactly the helpers it drives, so no emitted item is unused
and no dead_code allow is needed. The statics are shared across the gated
helpers, so reset() stays core and every test calls it first — which is
also the recording-fake convention; four from_unknown_body tests that had
omitted the reset() call now make it.

Update the call sites across network-web-auth, auth-commands, cli, and
publish to name their helpers.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JFCqwcs8qV7KqXqSyNvu3V
@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.00     10.5±0.17ms    35.7 MB/sec    1.00     10.5±0.19ms    35.8 MB/sec
packument/parse                                  1.01     38.5±0.49µs  1724.2 MB/sec    1.00     38.2±0.42µs  1734.4 MB/sec
tarball/download_dependency                      1.01      2.9±0.08ms  1493.1 KB/sec    1.00      2.9±0.07ms  1507.5 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00    163.3±0.90ms 98.0 KElem/sec    1.00    163.8±1.15ms 97.7 KElem/sec

@codecov-commenter

codecov-commenter commented Jul 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.92%. Comparing base (c2b7cfb) to head (2b3f53f).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13277   +/-   ##
=======================================
  Coverage   87.92%   87.92%           
=======================================
  Files         550      550           
  Lines       96449    96464   +15     
=======================================
+ Hits        84800    84819   +19     
+ Misses      11649    11645    -4     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 2b3f53f3aa1e

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time).

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.531 ± 0.187 2.335 2.781 1.65 ± 0.22
pacquet@main 2.453 ± 0.154 2.338 2.785 1.60 ± 0.20
pnpr@HEAD 1.530 ± 0.167 1.341 1.795 1.00
pnpr@main 1.565 ± 0.135 1.402 1.736 1.02 ± 0.14
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.53144657634,
      "stddev": 0.18692282244053895,
      "median": 2.4948355107399998,
      "user": 1.65960736,
      "system": 1.3008993199999999,
      "min": 2.33487004824,
      "max": 2.78121382724,
      "times": [
        2.36657120924,
        2.7767144362400002,
        2.78121382724,
        2.73105072424,
        2.6045283292400003,
        2.37017798624,
        2.33487004824,
        2.60140984924,
        2.35966818124,
        2.38826117224
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.45265402204,
      "stddev": 0.1544415195053384,
      "median": 2.3794958302399998,
      "user": 1.69179146,
      "system": 1.2508985200000002,
      "min": 2.33821850024,
      "max": 2.78473162624,
      "times": [
        2.33821850024,
        2.49289746424,
        2.67424212424,
        2.39410384924,
        2.35927779924,
        2.35668577524,
        2.40500346124,
        2.36488781124,
        2.78473162624,
        2.35649180924
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5304638378400002,
      "stddev": 0.16659618572409157,
      "median": 1.50207524074,
      "user": 1.1954571600000001,
      "system": 1.1270314200000002,
      "min": 1.34095535224,
      "max": 1.7953608392400002,
      "times": [
        1.53363620724,
        1.47350725724,
        1.7953608392400002,
        1.34095535224,
        1.42188673124,
        1.67812089424,
        1.35313077724,
        1.53064322424,
        1.40345628124,
        1.77394081424
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.56541635164,
      "stddev": 0.13511374563984965,
      "median": 1.57253425674,
      "user": 1.1987588599999999,
      "system": 1.13068562,
      "min": 1.40244031724,
      "max": 1.73649696724,
      "times": [
        1.68461189324,
        1.44092661324,
        1.64644128424,
        1.73649696724,
        1.6867279642400002,
        1.40322867724,
        1.4623630842400002,
        1.40244031724,
        1.69229948624,
        1.49862722924
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 251.4 ± 6.8 241.9 263.5 1.00
pacquet@main 253.5 ± 6.6 245.3 264.0 1.01 ± 0.04
pnpr@HEAD 266.0 ± 4.4 258.5 272.3 1.06 ± 0.03
pnpr@main 266.5 ± 5.4 258.9 274.5 1.06 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.25144449750000003,
      "stddev": 0.006777361132571335,
      "median": 0.25202997470000005,
      "user": 0.18699159999999998,
      "system": 0.51979216,
      "min": 0.2419051872,
      "max": 0.2634800212,
      "times": [
        0.24811637420000002,
        0.2419051872,
        0.2634800212,
        0.25681176320000004,
        0.25098175920000004,
        0.25307819020000005,
        0.25761061420000003,
        0.25318524620000005,
        0.2439085802,
        0.2453672392
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.2534511668000001,
      "stddev": 0.006592484749808275,
      "median": 0.25345348170000004,
      "user": 0.1901171,
      "system": 0.52559746,
      "min": 0.24531588720000003,
      "max": 0.26396229420000006,
      "times": [
        0.24977708820000002,
        0.25467973420000006,
        0.26396229420000006,
        0.2466097022,
        0.2459705262,
        0.24531588720000003,
        0.25562536420000004,
        0.26044121020000005,
        0.25990263220000004,
        0.25222722920000007
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.2659751948000001,
      "stddev": 0.00435925804216896,
      "median": 0.26620274720000003,
      "user": 0.21229019999999998,
      "system": 0.49900026,
      "min": 0.2585280562,
      "max": 0.27232938920000005,
      "times": [
        0.2646569012,
        0.2585280562,
        0.27232938920000005,
        0.26733653420000003,
        0.26942628120000006,
        0.27038082420000004,
        0.26701881220000007,
        0.2648420892,
        0.25984637820000006,
        0.26538668220000006
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.26653234410000004,
      "stddev": 0.005442687962605729,
      "median": 0.2654078432,
      "user": 0.1980908,
      "system": 0.52796806,
      "min": 0.25890097320000005,
      "max": 0.27449103720000007,
      "times": [
        0.2658217942,
        0.2599683782,
        0.2649938922,
        0.25890097320000005,
        0.26438647120000003,
        0.27355299620000006,
        0.27078148420000003,
        0.27449103720000007,
        0.26254466020000006,
        0.26988175420000005
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.584 ± 0.019 2.553 2.613 1.61 ± 0.16
pacquet@main 2.572 ± 0.014 2.546 2.589 1.60 ± 0.16
pnpr@HEAD 1.607 ± 0.160 1.421 1.860 1.00
pnpr@main 1.641 ± 0.153 1.428 1.868 1.02 ± 0.14
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.5836972857200005,
      "stddev": 0.01947645476182859,
      "median": 2.5859751275200002,
      "user": 1.66843936,
      "system": 1.30962156,
      "min": 2.55289629652,
      "max": 2.61311004652,
      "times": [
        2.56456758652,
        2.59962266952,
        2.61311004652,
        2.58776591552,
        2.57786995252,
        2.60600192952,
        2.56318820552,
        2.58507853852,
        2.58687171652,
        2.55289629652
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.57158909582,
      "stddev": 0.014305548290487233,
      "median": 2.57400599402,
      "user": 1.6467517600000001,
      "system": 1.3045493599999998,
      "min": 2.54602594052,
      "max": 2.58905703252,
      "times": [
        2.5876750185199997,
        2.56930315652,
        2.54602594052,
        2.56222863952,
        2.58905703252,
        2.55358677752,
        2.58065956652,
        2.57870883152,
        2.57978368152,
        2.56886231352
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.6070098684199998,
      "stddev": 0.15985747582609042,
      "median": 1.6400173150200001,
      "user": 1.18471146,
      "system": 1.1715705600000001,
      "min": 1.42070354052,
      "max": 1.86024701652,
      "times": [
        1.45257965552,
        1.44341181752,
        1.72549782952,
        1.78200662852,
        1.43532889352,
        1.62960604552,
        1.42070354052,
        1.65042858452,
        1.67028867252,
        1.86024701652
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.6406163084199998,
      "stddev": 0.15337911973164123,
      "median": 1.6289228635200002,
      "user": 1.1790519600000002,
      "system": 1.14565546,
      "min": 1.4280159695199999,
      "max": 1.86847251452,
      "times": [
        1.86847251452,
        1.4280159695199999,
        1.61377411452,
        1.4900656645199999,
        1.7540740075199999,
        1.72061917552,
        1.82581201552,
        1.62264295752,
        1.63520276952,
        1.44748389552
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 404.0 ± 12.7 385.7 426.2 1.36 ± 0.05
pacquet@main 388.5 ± 7.1 377.9 401.6 1.31 ± 0.04
pnpr@HEAD 300.7 ± 9.4 290.8 321.9 1.01 ± 0.04
pnpr@main 297.2 ± 6.2 286.3 307.5 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.40404444548,
      "stddev": 0.01267004389122413,
      "median": 0.40120965828,
      "user": 0.5261379800000001,
      "system": 0.6919403,
      "min": 0.38566966128,
      "max": 0.42621877828000004,
      "times": [
        0.40545269928000005,
        0.39919556628,
        0.40254546728,
        0.39765842728000006,
        0.39406912628,
        0.40500180128,
        0.42621877828000004,
        0.42475907828000004,
        0.39987384928,
        0.38566966128
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.3885200093800001,
      "stddev": 0.007141145867138808,
      "median": 0.38763440328000004,
      "user": 0.51755638,
      "system": 0.6583227999999999,
      "min": 0.37793475928000003,
      "max": 0.40162903928000004,
      "times": [
        0.38996623028000005,
        0.38462548328,
        0.37793475928000003,
        0.40162903928000004,
        0.38930115128000004,
        0.38596765528000004,
        0.39736612728000004,
        0.39155844428000003,
        0.38104925528000005,
        0.38580194828000003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30073731128,
      "stddev": 0.009353215403326127,
      "median": 0.29829550678000005,
      "user": 0.19686907999999997,
      "system": 0.5028298,
      "min": 0.29081614528000005,
      "max": 0.32188232828,
      "times": [
        0.29505565928000005,
        0.30180842628000004,
        0.29231119128000005,
        0.30083306428,
        0.29081614528000005,
        0.30420505328,
        0.32188232828,
        0.29544752228000004,
        0.29575794928000004,
        0.30925577328000003
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.29723787467999996,
      "stddev": 0.006212312063244336,
      "median": 0.29800990278000006,
      "user": 0.18503438,
      "system": 0.5083143999999999,
      "min": 0.28634166128000005,
      "max": 0.30752115728,
      "times": [
        0.30250690228000005,
        0.28994521828,
        0.30752115728,
        0.30038035228000004,
        0.29404763328000005,
        0.29498006928000003,
        0.29659090828,
        0.30063594728000004,
        0.29942889728000005,
        0.28634166128000005
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.737 ± 0.009 1.724 1.752 5.86 ± 0.10
pacquet@main 1.726 ± 0.011 1.711 1.748 5.82 ± 0.11
pnpr@HEAD 0.297 ± 0.005 0.289 0.306 1.00
pnpr@main 0.299 ± 0.004 0.294 0.307 1.01 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.7372456835199999,
      "stddev": 0.008880998442149539,
      "median": 1.7375193700199998,
      "user": 0.76359118,
      "system": 0.75016802,
      "min": 1.72400573152,
      "max": 1.75174100952,
      "times": [
        1.7447117695199998,
        1.75174100952,
        1.74558432052,
        1.73033499952,
        1.74228219052,
        1.7367334475199998,
        1.72400573152,
        1.72871355952,
        1.7300445145199999,
        1.73830529252
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.7258716945199999,
      "stddev": 0.011058062578634988,
      "median": 1.72241920102,
      "user": 0.7570609800000001,
      "system": 0.73528302,
      "min": 1.71099084252,
      "max": 1.74836290652,
      "times": [
        1.71488332252,
        1.71946144252,
        1.73447161652,
        1.7221458915199999,
        1.73023806052,
        1.72269251052,
        1.71099084252,
        1.73434724652,
        1.7211231055199998,
        1.74836290652
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29664888812,
      "stddev": 0.005035578260123103,
      "median": 0.29670002852,
      "user": 0.17819808,
      "system": 0.51529852,
      "min": 0.28867796752,
      "max": 0.30551229352,
      "times": [
        0.29599553352,
        0.29979053152,
        0.29014941252,
        0.29480422052,
        0.29765979252,
        0.29740452352,
        0.30551229352,
        0.28867796752,
        0.29482149252,
        0.30167311352
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.29920558111999995,
      "stddev": 0.004050501895312814,
      "median": 0.29908986652,
      "user": 0.18369977999999998,
      "system": 0.5160901200000001,
      "min": 0.29439605852,
      "max": 0.30700720252,
      "times": [
        0.29812758552,
        0.30025982552,
        0.29439605852,
        0.30138110852,
        0.30347591951999997,
        0.29685906752,
        0.29591157151999997,
        0.30700720252,
        0.30005214752,
        0.29458532452
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 198.3 ± 8.7 190.6 222.8 2.23 ± 0.13
pacquet@main 193.3 ± 4.3 185.1 202.8 2.17 ± 0.10
pnpr@HEAD 89.1 ± 3.5 84.9 98.6 1.00
pnpr@main 90.5 ± 4.4 85.2 100.1 1.02 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.19834092090769231,
      "stddev": 0.008678950240877765,
      "median": 0.1969041856,
      "user": 0.18948618769230768,
      "system": 0.07638439846153845,
      "min": 0.1906387296,
      "max": 0.2227891636,
      "times": [
        0.2227891636,
        0.1972530666,
        0.1906387296,
        0.1965125946,
        0.19183971060000002,
        0.19285168160000002,
        0.20769610060000002,
        0.1943002316,
        0.20100298960000001,
        0.1987696236,
        0.1969331936,
        0.1969041856,
        0.1909407006
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.19331799073333336,
      "stddev": 0.004326524350580696,
      "median": 0.19231972460000002,
      "user": 0.1810114133333333,
      "system": 0.07840505999999998,
      "min": 0.1850741876,
      "max": 0.20279786560000002,
      "times": [
        0.1934294526,
        0.19939408660000002,
        0.19224331860000002,
        0.1850741876,
        0.20279786560000002,
        0.19212757060000002,
        0.1942741116,
        0.1921398516,
        0.19231972460000002,
        0.1907805906,
        0.1965186026,
        0.1946660986,
        0.1957347006,
        0.1901584286,
        0.18811127060000002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08911283294375,
      "stddev": 0.003549668852691107,
      "median": 0.0884540481,
      "user": 0.021433255000000002,
      "system": 0.010806989375000001,
      "min": 0.0848523086,
      "max": 0.0985973016,
      "times": [
        0.0884150086,
        0.0867534056,
        0.0862321916,
        0.0856555646,
        0.0877653986,
        0.0884930876,
        0.0914312446,
        0.0885618176,
        0.0906418306,
        0.0867137576,
        0.0872716586,
        0.0867946256,
        0.0907148906,
        0.0976899326,
        0.0895405536,
        0.0923509736,
        0.0902230946,
        0.0961968966,
        0.0907245226,
        0.0907939006,
        0.0851597356,
        0.0985973016,
        0.0905173646,
        0.0852460916,
        0.0865484236,
        0.0870750446,
        0.0853743056,
        0.0851566036,
        0.0913550716,
        0.0871758866,
        0.0848523086,
        0.0915881606
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.09047933110000002,
      "stddev": 0.004438482764954254,
      "median": 0.0887735011,
      "user": 0.021271094285714283,
      "system": 0.012109686428571432,
      "min": 0.0852243756,
      "max": 0.1000835266,
      "times": [
        0.1000835266,
        0.0861909016,
        0.0873965146,
        0.0863450666,
        0.0866170196,
        0.0884426606,
        0.0905425566,
        0.0920068346,
        0.0862621306,
        0.0889103576,
        0.0978160386,
        0.0934925426,
        0.0862280886,
        0.0863900896,
        0.0932585726,
        0.0991596016,
        0.0909702456,
        0.0905808656,
        0.0852243756,
        0.0874429846,
        0.0868655026,
        0.09233178660000001,
        0.0979614356,
        0.0886366446,
        0.0879878916,
        0.0881554266,
        0.0973803326,
        0.0907412766
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.501 ± 0.131 4.407 4.842 1.27 ± 0.04
pacquet@main 4.599 ± 0.219 4.409 4.865 1.30 ± 0.07
pnpr@HEAD 3.540 ± 0.120 3.432 3.835 1.00 ± 0.04
pnpr@main 3.535 ± 0.058 3.455 3.624 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.501112536,
      "stddev": 0.13085133579643435,
      "median": 4.4477478335,
      "user": 1.8448615599999996,
      "system": 1.3622032799999997,
      "min": 4.406677545,
      "max": 4.841828385,
      "times": [
        4.571921591000001,
        4.439760496,
        4.452942843,
        4.406677545,
        4.424598721000001,
        4.544394232,
        4.43350588,
        4.4469846,
        4.448511067,
        4.841828385
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.5994715007,
      "stddev": 0.21889726701209897,
      "median": 4.449210766,
      "user": 1.8053651599999998,
      "system": 1.3910189800000001,
      "min": 4.408774481,
      "max": 4.86471194,
      "times": [
        4.436821537,
        4.408774481,
        4.862717387,
        4.461599995,
        4.436417117,
        4.831244581,
        4.412928966,
        4.853543881,
        4.425955122,
        4.86471194
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5395747661000003,
      "stddev": 0.1196354523518583,
      "median": 3.5027285375000003,
      "user": 1.30514066,
      "system": 1.2369704799999999,
      "min": 3.432285021,
      "max": 3.835271558,
      "times": [
        3.538508873,
        3.4785298840000003,
        3.5194716130000003,
        3.6256982310000003,
        3.4677037370000003,
        3.4427236490000004,
        3.4859854620000004,
        3.432285021,
        3.835271558,
        3.5695696330000004
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.5354789605000008,
      "stddev": 0.057969854395020025,
      "median": 3.558902463,
      "user": 1.29248086,
      "system": 1.2415785799999999,
      "min": 3.455450129,
      "max": 3.623828741,
      "times": [
        3.5584757970000003,
        3.5673678950000003,
        3.568300858,
        3.623828741,
        3.5598543620000003,
        3.5468841540000002,
        3.456381916,
        3.559329129,
        3.458916624,
        3.455450129
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13277
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,552.90 ms
(-5.15%)Baseline: 2,691.65 ms
3,229.98 ms
(79.04%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,724.01 ms
(-6.03%)Baseline: 1,834.67 ms
2,201.60 ms
(78.31%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
385.67 ms
(-20.50%)Baseline: 485.12 ms
582.14 ms
(66.25%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
190.64 ms
(-16.13%)Baseline: 227.32 ms
272.78 ms
(69.89%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,334.87 ms
(-4.30%)Baseline: 2,439.90 ms
2,927.88 ms
(79.75%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,406.68 ms
(-2.92%)Baseline: 4,539.08 ms
5,446.90 ms
(80.90%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
241.91 ms
(-15.82%)Baseline: 287.38 ms
344.86 ms
(70.15%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13277
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,420.70 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
288.68 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
290.82 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
84.85 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,340.96 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,432.29 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
258.53 ms
🐰 View full continuous benchmarking report in Bencher

@KSXGitHub KSXGitHub changed the title docs(guide/dev): test-fake macro-argument refactor(network-web-auth-testing): argument-gate web_auth_fake! helpers Jul 25, 2026
@KSXGitHub KSXGitHub changed the title refactor(network-web-auth-testing): argument-gate web_auth_fake! helpers refactor(pacquet/network-web-auth/test): argument-gate web_auth_fake! helpers Jul 25, 2026
claude added 2 commits July 31, 2026 01:51
Bring the login tests that #13479 added for headless web login
(no interactive terminal) into the argument-gated web_auth_fake!
convention: each names exactly the helpers it drives, since the
emit-everything expansion they were written against is gone.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JFCqwcs8qV7KqXqSyNvu3V
@KSXGitHub
KSXGitHub marked this pull request as ready for review August 1, 2026 04:38
Copilot AI review requested due to automatic review settings August 1, 2026 04:38
@KSXGitHub
KSXGitHub requested a review from zkochan as a code owner August 1, 2026 04:38
@greptile-apps

greptile-apps Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

The prior documentation contradiction is fixed: the guide now explicitly identifies capability providers as potentially optional, cites web_auth_fake! gating FakeHost, and the implementation matches that description; no blocking failure remains.

Reviews (2): Last reviewed commit: "docs(pacquet): note a shared fake can ga..." | Re-trigger Greptile

Comment thread pnpm/CODE_STYLE_GUIDE.md Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
pnpm/CODE_STYLE_GUIDE.md (1)

689-697: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep capability implementations optional in this guidance.

web_auth_fake! emits the state block and reset() unconditionally. It emits FakeHost and its capability implementations only when a test names FakeHost. Update the prose and example comment to match that contract.

🤖 Prompt for 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.

In `@pnpm/CODE_STYLE_GUIDE.md` around lines 689 - 697, Update the guidance around
the shared fake macro pattern, including the example comment and references to
web_auth_fake!, so the state block and reset() are always emitted while FakeHost
and its capability implementations are generated only when FakeHost is named by
a test. Preserve the variadic helper-name forwarding model and remove wording
that implies capability implementations are always emitted.
pnpm/crates/network-web-auth-testing/src/lib.rs (1)

270-339: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove documentation that restates generated helper names.

The set_*, infos, and warns rustdoc only describes each function body. Keep the macro-level contract and retain comments only where they explain a non-obvious invariant or test rationale.

As per coding guidelines, Rust comments must explain non-obvious invariants, workarounds, exceptions, or contracts rather than narrate code.

🤖 Prompt for 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.

In `@pnpm/crates/network-web-auth-testing/src/lib.rs` around lines 270 - 339,
Remove the function-level rustdoc comments from the generated helpers
set_stdin_tty, set_stdout_tty, set_time, set_sleep_behavior, set_input,
set_fetch, infos, and warns, while preserving the helper implementations and
macro-level documentation or comments that describe non-obvious contracts or
test invariants.

Sources: Coding guidelines, Path instructions

🤖 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/network-web-auth-testing/src/lib.rs`:
- Around line 341-348: Add a #[diagnostic] compile-fail regression test for the
public web_auth_fake! macro’s unknown-helper catch-all arm, invoking an invalid
helper and asserting the emitted unknown-helper diagnostic includes the
authoritative expected-helper list. Keep the test minimal and ensure it fails
compilation specifically through the ::std::compile_error! branch.

---

Nitpick comments:
In `@pnpm/CODE_STYLE_GUIDE.md`:
- Around line 689-697: Update the guidance around the shared fake macro pattern,
including the example comment and references to web_auth_fake!, so the state
block and reset() are always emitted while FakeHost and its capability
implementations are generated only when FakeHost is named by a test. Preserve
the variadic helper-name forwarding model and remove wording that implies
capability implementations are always emitted.

In `@pnpm/crates/network-web-auth-testing/src/lib.rs`:
- Around line 270-339: Remove the function-level rustdoc comments from the
generated helpers set_stdin_tty, set_stdout_tty, set_time, set_sleep_behavior,
set_input, set_fetch, infos, and warns, while preserving the helper
implementations and macro-level documentation or comments that describe
non-obvious contracts or test invariants.
🪄 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: b6cb4713-1459-46d0-acd1-43801101949f

📥 Commits

Reviewing files that changed from the base of the PR and between a99b852 and 0990ca1.

📒 Files selected for processing (10)
  • pnpm/CODE_STYLE_GUIDE.md
  • pnpm/crates/auth-commands/src/login/test_classic_login.rs
  • pnpm/crates/auth-commands/src/login/test_non_interactive.rs
  • pnpm/crates/auth-commands/src/login/test_web_login.rs
  • pnpm/crates/auth-commands/src/login/test_web_login_errors.rs
  • pnpm/crates/auth-commands/src/login/test_web_login_scope.rs
  • pnpm/crates/cli/src/cli_args/login/tests.rs
  • pnpm/crates/network-web-auth-testing/src/lib.rs
  • pnpm/crates/network-web-auth/tests/with_otp_handling.rs
  • pnpm/crates/publish/src/publish_packed_pkg/tests.rs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors the Rust web_auth_fake! test macro (in crates/network-web-auth-testing) to avoid emitting unused helpers and suppressing them with #[allow(dead_code)], by generating optional helpers only when explicitly requested via named macro arguments. This aligns test infrastructure with the documented macro-argument gating pattern and updates call sites accordingly.

Changes:

  • Updated web_auth_fake! to always emit only the thread_local! statics + reset(), and to generate FakeHost, reporters, setters, and message queries only when named (with a catch-all compile_error! for unknown helpers).
  • Updated all web_auth_fake! call sites across affected test suites to list the helpers they actually use (and ensured reset() is called where needed).
  • Added documentation to pnpm/CODE_STYLE_GUIDE.md describing the argument-gating technique for shared stateful test fakes.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pnpm/crates/network-web-auth-testing/src/lib.rs Refactors web_auth_fake! to gate optional helpers behind named macro arguments and removes blanket dead_code suppression.
pnpm/crates/network-web-auth/tests/with_otp_handling.rs Updates tests to request only needed web_auth_fake! helpers; adds reset() where required.
pnpm/crates/auth-commands/src/login/test_web_login.rs Updates web_auth_fake! invocations to specify required helpers.
pnpm/crates/auth-commands/src/login/test_web_login_scope.rs Updates web_auth_fake! invocations to specify required helpers.
pnpm/crates/auth-commands/src/login/test_web_login_errors.rs Updates web_auth_fake! invocations to specify required helpers.
pnpm/crates/auth-commands/src/login/test_non_interactive.rs Updates web_auth_fake! invocation to specify required helpers.
pnpm/crates/auth-commands/src/login/test_classic_login.rs Updates web_auth_fake! invocations to specify required helpers.
pnpm/crates/cli/src/cli_args/login/tests.rs Updates web_auth_fake! invocations to specify required helpers.
pnpm/crates/publish/src/publish_packed_pkg/tests.rs Updates web_auth_fake! invocations to specify required helpers.
pnpm/CODE_STYLE_GUIDE.md Documents the macro argument-gating pattern for shared stateful DI fakes (and the compile_error! catch-all arm).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The 'Sharing a stateful fake across many tests' guidance listed the
capability impls among the always-emitted core, but web_auth_fake! gates
its FakeHost provider behind a named argument like any other optional
item. Reword so the core is only what every test drives and note that a
provider can itself be optional.
Copilot AI review requested due to automatic review settings August 1, 2026 11:50
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Responding to the CodeRabbit review — verdicts on its three points:

  • Compile-fail test for the unknown-helper arm (the one actionable) — declined; reasons in the thread: it needs a new trybuild dev-dependency that doesn't exist anywhere in pnpm/ (and AGENTS.md forbids adding one without sign-off), it would be inconsistent with the seven sibling gated fakes that all have the same catch-all arm and no such test, and the arm is a static literal so a snapshot would be low-value and brittle.
  • Nitpick — capability impls listed as always-emitted core — valid; fixed in 2b3f53f and resolved. The core is now described as only what every test drives, with a note that a provider like FakeHost can be gated too.
  • Nitpick — drop the per-helper rustdocs — declined. They aren't pure restatement of the bodies: set_time documents the millisecond unit (the parameter is a bare u64), set_stdin_tty records that it drives the interactive-prompt gate, and infos / warns document the pnpm:global channel and the reporter they read from. The macro-level list is terser and doesn't carry those specifics, so removing them would drop contract rather than noise.

Generated by Claude Code

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Suppressed comments (1)

pnpm/crates/network-web-auth-testing/src/lib.rs:348

  • The catch-all arm qualifies built-in macros as ::std::compile_error!/concat!/stringify!, but the established pattern in this repo’s test fakes uses the unqualified forms (e.g. crates/auth-commands/src/login/support.rs:111). Using the unqualified macros keeps the style consistent and avoids relying on std macro re-exports.
    (@helper $unknown:ident) => {
        ::std::compile_error!(::std::concat!(
            "unknown `web_auth_fake!` helper `",
            ::std::stringify!($unknown),

@zkochan
zkochan merged commit 3f900cd into main Aug 1, 2026
39 checks passed
@zkochan
zkochan deleted the claude/test-fake-macro-arg-docs-ciq394 branch August 1, 2026 12:29
KSXGitHub pushed a commit that referenced this pull request Aug 1, 2026
Brings in 42 commits, including the pnpm 11.19.0 / pacquet 12.0.0-beta.2
releases, the resolver and peer-hoisting performance work, and the napi
readConfig additions.

Git merged every overlapping file without a textual conflict, but one
change needed a semantic fixup: #13277 argument-gates `web_auth_fake!`, so
the two scope tests added on this branch had to name the helpers they use
(`FakeHost`, `RecordingReporter`, `set_fetch`) instead of calling the macro
bare. Without it the crate would still merge cleanly and then fail to
compile.
@coderabbitai coderabbitai Bot mentioned this pull request Aug 3, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document the test-fake macro-argument technique (avoid #[allow(dead_code)]) in the agent guides

5 participants