Repository navigation
refactor(pacquet/network-web-auth/test): argument-gate web_auth_fake! helpers - #13277
Conversation
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
|
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)
📝 WalkthroughWalkthroughThe ChangesWeb-auth fake helper generation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 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 |
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
Micro-Benchmark ResultsLinux |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Commit: 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
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
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
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
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
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
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
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
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13277 |
| Testbed | pnpr |
⚠️ 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-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 1,420.70 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 288.68 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 290.82 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 84.85 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,340.96 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,432.29 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 258.53 ms |
web_auth_fake! helpers
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
Confidence Score: 5/5The PR appears safe to merge. The prior documentation contradiction is fixed: the guide now explicitly identifies capability providers as potentially optional, cites Reviews (2): Last reviewed commit: "docs(pacquet): note a shared fake can ga..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
pnpm/CODE_STYLE_GUIDE.md (1)
689-697: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winKeep capability implementations optional in this guidance.
web_auth_fake!emits the state block andreset()unconditionally. It emitsFakeHostand its capability implementations only when a test namesFakeHost. 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 winRemove documentation that restates generated helper names.
The
set_*,infos, andwarnsrustdoc 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
📒 Files selected for processing (10)
pnpm/CODE_STYLE_GUIDE.mdpnpm/crates/auth-commands/src/login/test_classic_login.rspnpm/crates/auth-commands/src/login/test_non_interactive.rspnpm/crates/auth-commands/src/login/test_web_login.rspnpm/crates/auth-commands/src/login/test_web_login_errors.rspnpm/crates/auth-commands/src/login/test_web_login_scope.rspnpm/crates/cli/src/cli_args/login/tests.rspnpm/crates/network-web-auth-testing/src/lib.rspnpm/crates/network-web-auth/tests/with_otp_handling.rspnpm/crates/publish/src/publish_packed_pkg/tests.rs
There was a problem hiding this comment.
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 thethread_local!statics +reset(), and to generateFakeHost, reporters, setters, and message queries only when named (with a catch-allcompile_error!for unknown helpers). - Updated all
web_auth_fake!call sites across affected test suites to list the helpers they actually use (and ensuredreset()is called where needed). - Added documentation to
pnpm/CODE_STYLE_GUIDE.mddescribing 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.
|
Responding to the CodeRabbit review — verdicts on its three points:
Generated by Claude Code |
There was a problem hiding this comment.
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 onstdmacro re-exports.
(@helper $unknown:ident) => {
::std::compile_error!(::std::concat!(
"unknown `web_auth_fake!` helper `",
::std::stringify!($unknown),
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.
Summary
web_auth_fake!— the shared OTP / web-auth test fake incrates/network-web-auth-testing— emitted its whole surface (FakeHostwith its eight capability impls, both reporters, everyset_*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 andreset()as the always-present core and gates each optional helper (FakeHost,RecordingReporter,UnexpectedReporter, theset_*setters,infos,warns) behind a named macro argument, with a catch-allcompile_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 innetwork-web-auth,auth-commands,cli, andpublishare updated accordingly.pnpm/CODE_STYLE_GUIDE.mddocuments the convention (new "Sharing a stateful fake across many tests" subsection), withlogin_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
Checklist
pnpm/port, or notes what still needs porting. — Pacquet-only test-infrastructure and guide change; no TypeScript-CLI counterpart applies.web_auth_fake!fake and its call sites; the affected suites (network-web-auth,auth-commands,cli,publish) pass locally.CODE_STYLE_GUIDE.mdsubsection.Summary by CodeRabbit
Tests
Documentation
Summary by CodeRabbit
Tests
Documentation