Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Move patch/redirect/mod.rs's inline test modules into sibling test files

未关闭 适合新手
#1,011 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
tooling

调研方向

从 crates/socket-patch-core/src/patch/redirect/mod.rs 开始:生产代码到 L7622 结束,mod tests 占据 L7623–L21402,另有五个 #[cfg(test)] 模块一直到 L21936。将每个模块体原样(verbatim)移入同级文件(redirect/tests.rs、python_lock_warning_tests.rs 等),在 mod.rs 中以 #[cfg(test)] mod ...; 声明它们,用 use super::* 处理可见性,并以现有的 *_equivalence_tests.rs 文件(L33–L49)为范例。当 cargo test -p socket-patch-core redirect:: 显示 307/322 个测试照常通过、cargo clippy -p socket-patch-core --all-targets 无警告、且 git diff --color-moved=zebra 只显示被移动的代码块时即为完成。

由索引模型根据 Issue 内容生成。

描述

arch-audit refactor

[agent] Filed by the scheduled architecture audit routine (ecosystems and formats). Register: register comment.

Kind: refactor. Source: §3.7 #1 (step 1 of tracking #1010). Register E30.

Problem

About two thirds of patch/redirect/mod.rs (21,936 lines at db83f01) is inline tests:

  • mod tests, L7623–L21402: 13,780 lines and 307 tests (322 across all six modules), covering every ecosystem's rewriter;
  • python_lock_warning_tests (L21403), python_metadata_pairing_tests (L21445), hatch_tests (L21546), hosted_patch_uuid_tests (L21665) and superseding_repin_tests (L21792–L21936).

The production code ends at L7622. The sibling *_equivalence_tests.rs files already use the sibling-file pattern (L35–L45).

Impact
  • Each hosted test addition creates a conflict hotspot in the same file as the production code.
  • Production review is buried in a 22K-line file.
  • This is the cheapest step of the split, and it removes about 14.3K lines from mod.rs without touching a production line.
Proposed change
  • Declare the modules from mod.rs and move each one's body verbatim into its own file: #[cfg(test)] mod tests; → redirect/tests.rs, and likewise python_lock_warning_tests.rs, python_metadata_pairing_tests.rs, hatch_tests.rs, hosted_patch_uuid_tests.rs and superseding_repin_tests.rs.
  • Inside each file, use super::* keeps the same visibility, so no item changes visibility.
  • Optional, in a follow-up and not this PR: split tests.rs per ecosystem once the production split (later steps of #1010) lands.

Deleted from mod.rs: L7623–L21936.

Size and scope
  • Files: redirect/mod.rs and six new sibling files.
  • About 14.3K moved lines, 0 changed production lines, and about 12 added declaration lines.
  • Out of scope: any production move, any test edit or rename, and the equivalence suites.
Acceptance criteria
  • git diff --color-moved=zebra shows only moved blocks, plus the six mod declarations.
  • mod.rs is ≤ ~7.7K lines.
  • cargo test -p socket-patch-core redirect:: runs the same number of tests before and after (307 in tests and 322 across the six modules), and all of them pass.
  • cargo clippy -p socket-patch-core --all-targets is clean (no new unused warnings from the move).
Dependencies

None. It is best landed when few PRs touching redirect/mod.rs tests are open, because open PRs will need a trivial rebase onto the moved file. It is step 1 of #1010 and unblocks nothing technically, but it makes steps 2–7 reviewable.

主要语言
Rust
星标
8
派生
0
平均合并
1 天 1 小时
30 天内合并 PR
211

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

SocketDev/socket-patch 的其他 Issue

查看 SocketDev/socket-patch 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。