Flake: composer oracle test races the COMPOSER_VENDOR_DIR EnvGuard added in #2064

未关闭
#2,072 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
半天
新手友好度
50/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
rust
领域
testing

调研方向

Start in crates/socket-patch-core/src/crawlers/composer_crawler.rs: the failing randomized_vendor_trees_match_the_async_oracle test is near line 2504, and the injected var("COMPOSER_VENDOR_DIR") closure is near line 723. Read test_env.rs for how guarded_var_os and EnvGuard interact, and the vendor_dir_lookups_ignore_the_hosts_composer_env test that holds the guard. Done means the equivalence test passes reliably when run alongside the guard test, with the chosen fix documented.

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

描述

agent:triaged ci-janitor priority:p2

New race on main since #2064 (7c5240e, merged 2026-11-13 15:13 UTC). It already failed one coverage shard.

Evidence

  • PR #2071 (a CI-only change, unrelated to composer), coverage (1), run https://github.com/SocketDev/socket-patch/actions/runs/43499592420/job/132141704760:
    crawlers::composer_crawler::tests::equivalence::randomized_vendor_trees_match_the_async_oracle panicked at crates/socket-patch-core/src/crawlers/composer_crawler.rs:2504:
    seed 3: crawl_all left: [("b", "3.5.0", …"/proj/web/plugins/p0"), ("plugin", "3.5.0", …"/proj/vendor/wp/plugin")] right: []
    The fixture is deterministic (seeded), so one of the two crawlers saw a different vendor dir partway through the test.

Root cause
Under cfg(test), the composer crawler reads COMPOSER_VENDOR_DIR through test_env::guarded_var_os, which returns the real value whenever any live EnvGuard holds the key. #2064 added vendor_dir_lookups_ignore_the_hosts_composer_env, which ends with EnvGuard::set("COMPOSER_VENDOR_DIR", "held"). That test is #[serial], but the readers (randomized_vendor_trees_match_the_async_oracle and the other composer crawl tests) are not. serial only excludes other serial tests, so a parallel reader can see vendor-dir = held (a directory that doesn't exist) for the guard's lifetime. The new crawler resolved before the guard and the legacy one during it, or the other way round, and the results diverged.

The same pattern can hit any env that guarded_var gates (ruby_crawler's Bundler vars, utils::go_env) wherever a guard-holding test runs beside non-serial readers.

Fix options

  1. Test the "a held value is honoured" half through the injected-var resolver (the var("COMPOSER_VENDOR_DIR") closure path at ~L723) instead of a process-wide guard, and keep only the "host value hidden" half on the real env. This is the smallest fix.
  2. Or mark the env readers in that module #[serial_test::parallel], which excludes them from running beside #[serial] tests, and document the rule in test_env.rs ("every user must also be serial" covers writers but not readers).

Frequency: 1 hit so far (needs the two tests to overlap). It's in the gating coverage leg, so in the merge queue one hit evicts an entry.

Filed by the hourly CI janitor.


Generated by Claude Code

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

环境准备

  • 没有 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 摘要。