Share one scoped env-var test guard: EnvGuard is copy-pasted 11 times across core unit and integration tests
維護者通常 1 天內回覆
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 55/100
- Issue 類型
- 重構
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- rust
研究方向
Start by reading the EnvGuard definitions named in the issue and the core test helper beside test_rng. Compare the unit-test and integration-test variants, including the OsStr and closure forms, then identify any existing injected-env helpers and test-support setup. Done means the touched tests share the guard, retain their existing #[serial] usage, and the stated grep finds one core definition.
由索引模型根據 Issue 內容生成。
描述
[agent] Filed by the scheduled architecture audit (audit-core). Register: register.
Kind: refactor (tests). Register ID: A37.
Problem
Tests that mutate process env each define their own restore-on-drop guard.
These three copies are byte-identical:
- go_crawler.rs L1518-L1542
- deno_crawler.rs L945-L969
- maven_crawler.rs L2508-L2532
These are variants:
npm_crawler.rsL5880, which takes anOsStrvaluepython_crawler.rsL7878 and L8107vendor/maven_repo.rsL2649patch/jvm_jar.rsL837tests/upstream_restore_golden.rsL188tests/crawler_deno_e2e.rsL24tests/crawler_npm_e2e.rsL357
There are also closure-style twins: utils/socket_cli_config.rs with_env (L311) and utils/fs.rs with_home_env (L1489).
grep -rn "struct EnvGuard" crates finds 11 definitions.
Proposed change
- Add one
#[cfg(test)] pub(crate) mod test_envin core, besidetest_rng. It holdsEnvGuard::set(key, value),::unset(key)and a multi-key form takingOsStrvalues, pluswith_env(pairs, f). - Unit tests use it.
- The three integration-test files share one copy in
tests/common/, or through atest-supportfeature if one already exists. - Where a function under test already takes injected env (
*_withvariants), switch the test to that and drop the guard.
Size
About 12 files, about −150 lines. Tests only.
Acceptance criteria
- No production code changes.
- Every touched test still runs under
#[serial]where it did before and passes. grep -rn "struct EnvGuard" crates/socket-patch-core/srcfinds one definition.
- 主要語言
- Rust
- 星號
- 8
- 分支
- 2
- 平均合併
- 19 小時 12 分鐘
- 30 天內合併 PR
- 709
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
SocketDev/socket-patch 的其他 Issue
-
agent:triaged arch-audit priority:p3 refactor
難度 2/5 1-3 小時 新手友好度 83/100
SocketDev/socket-patch#1860 ·
維護者通常 1 天內回覆
-
agent:triaged arch-audit priority:p3 refactor
難度 2/5 1-3 小時 新手友好度 78/100
SocketDev/socket-patch#1838 ·
維護者通常 1 天內回覆
-
Memoize env-keyed subprocess probes through one helper: composer, python and ruby each define the same env key and drifted on when an answer is kept可能已有人在做 @mikolalysenko 於 1 天前認領。 未關閉agent:claimed agent:triaged arch-audit priority:p1 refactor
難度 4/5 1-2 天 新手友好度 25/100
SocketDev/socket-patch#1888 · 3 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged arch-audit priority:p3 refactor
難度 4/5 1-2 天 新手友好度 55/100
SocketDev/socket-patch#1887 · 1 則留言 ·
維護者通常 1 天內回覆
-
agent:needs-human agent:triaged arch-audit priority:p3 refactor
難度 4/5 3-5 天 新手友好度 38/100
SocketDev/socket-patch#1881 ·
維護者通常 1 天內回覆
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 62/100
calcit-lang/caps#16 ·
-
難度 2/5 1-3 小時 新手友好度 85/100
penso/herdr-gpui#934 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
Y-ASLant/ElegantClipboard#178 ·
-
難度 2/5 1-3 小時 新手友好度 82/100
linxiv-dev/linXiv#384 · 1 則留言 ·
維護者通常 1 天內回覆
-
priority middle
難度 2/5 1-3 小時 新手友好度 70/100
KATO-Hiro/AtCoderClans#12945 ·
維護者通常 1 天內回覆