Copy test fixture trees through one tests/common::copy_tree: 38 recursive copiers, 20 identical

Ouverte
#1,979 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
62/100
Type d'issue
Refactorisation
Clarté
Clairement spécifiée
Activité
Active
Stack technique
rust
Domaine
testing

Piste de recherche

Start with the identical copies in crates/socket-patch-cli/tests/e2e_redirect_cargo_build.rs (around L139) and mode_migration_npm.rs (around L120), then add one copy_tree to tests/common/mod.rs. The drifted callers need separate handling: the gem copy at e2e_redirect_gem_build.rs L253 silently accepts a missing source, and the skip-list and walkdir variants need a copy_tree_except only where they are used. Done when cargo test -p socket-patch-cli --tests --no-run builds, the touched suites pass, and the grep for fn copy_tree( or fn copy_dir_recursive( returns only tests/common/.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

agent:triaged arch-audit priority:p3 refactor

[agent] Filed by the scheduled architecture audit (audit-cli-tests). Register: register.

Kind: refactor. Register ID: T64.

Problem

crates/socket-patch-cli/tests has 38 recursive directory copiers: 26 copy_dir_recursive, 12 copy_tree and a few copy_dir. tests/common has none, although 129 suites include it.

  • Identical copies. 20 bodies are identical after whitespace normalization, for example e2e_redirect_cargo_build.rs L139,`` e2e_vendor_golang_build.rs L220 and mode_migration_npm.rs L120.```` The full list:
    • e2e_redirect_{bun,cargo,pnpm,yarn_berry,yarn_classic}_build
    • e2e_vendor_{bun,cargo,gem,golang,pnpm,pypi,yarn_berry,yarn_classic}_build
    • e2e_vendor_yarn_classic_dev_flow
    • e2e_vendored_production
    • e2e_yarn4_{pnpm_linker,workspaces}_build
    • mode_migration_{bun,cargo,npm}
  • Already "shared" copies. Three crate-local modules export the same body as pub: composer_e2e_common L323,````` maven_build_common L509 and `npm_e2e_common/manifestless.rs` L30. `prebuilt_common` keeps a private copy at L722,`````` and `e2e_nuget_dotnet_build.rs` L320 re-copies it.
  • Drifted copies. The other 15 have drifted:
    • e2e_redirect_gem_build.rs L253 silently accepts a missing source.
    • Some copies take a skip list: copy_tree(from, to, skip) ×2.
    • e2e_gradle_agent_build.rs L1077 walks with walkdir.
    • e2e_embedded_vex.rs L279 copies one level only.

Same family, also to collapse once the helper exists:

  • Scan proxy. start_proxy and assert_proxy_served_scans are byte-identical in e2e_cargo.rs L33/L112, e2e_composer.rs L31/L79, e2e_maven.rs L33/L91 and e2e_nuget.rs L33/L162. e2e_gem.rs L292 is a deliberate by-package variant, but the composer doc still says that suite has the same shape.
  • Hosted pins. hosted_pin_count is written ×8 (e.g. e2e_hosted_production.rs L421, e2e_bun_lockb.rs L125, in_process_vendor.rs L290) and hosted_pinned ×14, beside common::envelope::hosted_pins.
Proposed change
  1. Add pub fn copy_tree(from: &Path, to: &Path) to tests/common/mod.rs, using the identical body above.
  2. Delete the 20 identical copies, the 4 *_common copies and the nuget copy. Import from common instead.
  3. For the drifted callers:
    • Keep a skip-list or missing-source variant only where a caller needs it, as copy_tree_except(from, to, skip) in the same module.
    • Make the gem caller check existence itself.
  4. Optional follow-up in the same PR or the next one:
    • Move the 4 identical start_proxy/assert_proxy_served_scans into a tests/common/scan_proxy.rs.
    • Replace hosted_pin_count with envelope::hosted_pins(..).len().
Size

About 40 test files. Roughly −450 lines.

Acceptance criteria
  • No test changes its assertions. The touched suites build and pass: cargo test -p socket-patch-cli --tests --no-run, plus the host-runnable ones that use the copies (mode_migration_*, e2e_redirect_cargo_build).
  • grep -rnE "fn (copy_tree|copy_dir_recursive)\(" crates/socket-patch-cli/tests shows only common/.
Langage dominant
Rust
Étoiles
9
Forks
2
Merge moyen
1 j 8 h
PR mergées (30 j)
309

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de SocketDev/socket-patch

Toutes les issues de SocketDev/socket-patch

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.