Gradle --global-prefix e2e tests pass without --global-prefix: the harness always sets GRADLE_USER_HOME, and no test asserts gradle_user_home_differs fires

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

Start with global_prefix_scan_says_nothing_about_the_user_home in crates/socket-patch-cli/tests/e2e_gradle_discovery_build.rs, then isolate_cli in tests/common/jvm_env.rs, which always sets GRADLE_USER_HOME. Remove that variable after prepare_command, add a positive control asserting gradle_user_home_differs appears without --global-prefix, and then assert it is absent with the flag. The same pattern applies to gradle_agent_global_prefix in e2e_gradle_agent_build.rs. Done means both tests fail when --global-prefix handling is stubbed out.

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

描述

agent:triaged arch-audit bug priority:p3

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

Kind: bug (fake tests). Register ID: T67.

Problem

Two Gradle tests claim to prove --global-prefix behavior, but the harness makes the flag irrelevant to their assertions.

e2e_gradle_discovery_build.rs. global_prefix_scan_says_nothing_about_the_user_home`` asserts that gradle_user_home_differs is absent. The warning can't appear in this harness, because:

  • the scan goes through jvm_env::isolate_cli, which always sets GRADLE_USER_HOME (jvm_env.rs L106-L109);
  • the core check returns None whenever GRADLE_USER_HOME is set (gradle_cache.rs L551-L566).```

Executed on cbbbdb9 with a scratch build, running scan --json in a Gradle project with HOME ≠ passwd home:

Case warnings[] codes
GRADLE_USER_HOME unset ["gradle_user_home_differs"]
GRADLE_USER_HOME set (the harness) []
--global-prefix, GRADLE_USER_HOME unset []

So the assertion holds whether or not --global-prefix suppresses the warning. The suite's scan doc at L111 says None means "no GRADLE_USER_HOME", which is false. No CLI test anywhere asserts that gradle_user_home_differs fires.

e2e_gradle_agent_build.rs. gradle_agent_global_prefix runs through socket(), which sets GRADLE_USER_HOME to the same cache (L333).````` A plain apply --offline already patches that cache (L468), so a CLI that ignored `--global-prefix` would still pass. This one comes from reading the code and was not executed.

Proposed change

For the discovery test:

  • Remove GRADLE_USER_HOME after prepare_command.
  • Add a positive control: the same scan without --global-prefix asserts gradle_user_home_differs is present.
  • Then assert it is absent with the flag.
  • Fix the L111 doc.

For the agent test:

  • Remove GRADLE_USER_HOME, or point it at an empty dir, so only --global-prefix names the cache.
  • Assert the jar is patched there and untouched under the default home.
Size

2 test files. About +30/−10 lines.

Acceptance criteria
  • Each test fails when --global-prefix handling is stubbed out. Show this once by mutation in the PR description.
  • The new positive control passes on main.
主要语言
Rust
星标
9
派生
2
平均合并
18 小时 47 分钟
30 天内合并 PR
637

环境准备

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