Skip to content

test(maven): 模型回归隔离本机 Maven 设置(#36) - #43

Merged
1lck merged 2 commits into
mainfrom
lithe-support/issue-36-isolate-maven-settings
Nov 23, 2026
Merged

1lck merged 2 commits into
mainfrom
lithe-support/issue-36-isolate-maven-settings

Conversation

@lithe-support

@lithe-support lithe-support Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #36

根因

scripts/test.mjs 的主模型和扩展 Boot 模型使用 run() 调 Maven,却未显式指定 -gs、-s;本机 ~/.m2/settings.xml 若含额外 profile,model.optionValues.profiles 就会多出用户配置,导致原有 ["ci", "release"] 断言失败。readProfileModel 原来已有隔离设置,行为不一致。此外,prepareRuns、verifyExtendedBootAndProvided 通过 lithe-maven-provider.jar 启动的 Maven 进程,以及 scripts/compiler/test.mjs 中的 Maven 调用也会受到 MAVEN_ARGS 和本机 ~/.m2/settings.xml 影响。

修复

  • 测试沙盒创建一份空 Maven 设置文件,所有 run() 调用通过 modelSettings() 指定全局和用户设置;覆盖主模型、依赖、扩展模型和测试命令。
  • readProfileModel 复用 helper,保留测试指定的 settings.xml 覆盖值。
  • 不带 Lithe 属性的直接 Maven 调用也使用隔离设置。
  • prepareRuns 与 verifyExtendedBootAndProvided 启动 BackendClient 时清除 MAVEN_ARGS,并在 lithe/build/prepareRun 的 optionArguments 中传入 modelSettings(),隔离 provider 内部拉起的 Maven 进程。
  • scripts/compiler/test.mjs 的 Maven model() 与 compile 调用同样使用空设置文件并清除 MAVEN_ARGS。
  • 所有上述 Maven 调用清除继承的 MAVEN_ARGS,防止环境参数污染。
  • 不修改插件产物、协议或业务实现;已有 Profiles 和 settings.xml 检查作为回归断言。

本地验证(macOS arm64, JDK 17.0.18, Apache Maven 3.9.14, Node v24.14.0)

  • node scripts/test-process.mjs — 9/9 通过
  • node scripts/package.mjs — 通过,打包 dist/maven-build-1.0.3-{darwin,linux,windows}.zip
  • MAVEN_ARGS="--invalid-flag-from-env" node scripts/test.mjs — 全部通过(验证环境变量污染被完全隔离)
  • node --test --test-timeout=15000 scripts/compiler/process.test.mjs — 2 通过, 1 Windows 专用跳过(macOS 预期)
  • MAVEN_ARGS="--invalid-flag-from-env" node scripts/compiler/test.mjs — 5/5 通过
  • node --test --test-timeout=60000 scripts/package/*.test.mjs — 3/3 通过
  • 确认无残留 Java/Maven 进程;未涉及 UI 改动无需截图。

@1lck
1lck marked this pull request as ready for review November 23, 2026 13:03
@1lck
1lck merged commit d430470 into main Nov 23, 2026
17 of 19 checks passed
@1lck
1lck deleted the lithe-support/issue-36-isolate-maven-settings branch November 23, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: scripts/test.mjs 的主模型用例读取本机 ~/.m2/settings.xml,本机有 profile 时失败

1 participant