Share one scoped env-var test guard: EnvGuard is copy-pasted 11 times across core unit and integration tests
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 55/100
- Type d'issue
- Refactorisation
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- rust
- Domaine
- developer-experience, testing
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
[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.
- Langage dominant
- Rust
- Étoiles
- 8
- Forks
- 2
- Merge moyen
- 19 h 12 min
- PR mergées (30 j)
- 709
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de SocketDev/socket-patch
-
agent:triaged arch-audit priority:p3 refactor
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
SocketDev/socket-patch#1860 ·
Les mainteneurs répondent en général sous 1 jour
-
agent:triaged arch-audit priority:p3 refactor
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
SocketDev/socket-patch#1838 ·
Les mainteneurs répondent en général sous 1 jour
-
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 keptPeut-être pris @mikolalysenko l’a pris aujourd’hui. Ouverteagent:claimed agent:triaged arch-audit priority:p1 refactor
Difficulté 4/5 1-2 jours Accessibilité débutants 25/100
SocketDev/socket-patch#1888 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
agent:triaged arch-audit priority:p3 refactor
Difficulté 4/5 1-2 jours Accessibilité débutants 55/100
SocketDev/socket-patch#1887 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
agent:needs-human agent:triaged arch-audit priority:p3 refactor
Difficulté 4/5 3-5 jours Accessibilité débutants 38/100
SocketDev/socket-patch#1881 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de SocketDev/socket-patch
Issues similaires
-
bug priority: low ui
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
storytold/photocraft#10370 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
area:doc bug in progress needs-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
bherbruck/solvecraft#9634 · 2 commentaires · 1 réaction ·
-
inflate: total_in uses plain += on c_ulong (32-bit on Windows), panics in debug for streams > 4 GiBOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
trifectatechfoundation/zlib-rs#570 · 1 commentaire ·
-
bug discord-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
LanternOps/breeze#10755 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
aranya-project/aranya#803 ·