Skip to content

fix(tests): isolate cli_tests from host Winuxsh install env - #996

Merged
caomengxuan666 merged 2 commits into
masterfrom
fix/test-isolation
Oct 22, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
fix/test-isolation

Conversation

@arookieofc

Copy link
Copy Markdown
Member

Summary

cli_tests fails on Windows hosts that have a Winuxsh/niubash install, even though the engine is fine. This PR fixes the test isolation; no engine code changes.

  • Host install env leaks into spawned engines: installing niu exports WINUXSH_ROOT to the user environment. The root resolution order is __RUBASH_SHELL_ROOT > WINUXSH_ROOT > RUBASH_ROOT, so the fixture's RUBASH_ROOT got shadowed (e.g. tilde_user ×3 expanding against the installed tree). All cli_tests engine spawns now go through a rubash_command() helper that strips WINUXSH_ROOT / __RUBASH_SHELL_ROOT.
  • Brackets in PATH entries: the fd_redirects external-fd-copy bin dirs were named with ThreadId(N) Debug output; Windows .cmd resolution through a PATH entry containing brackets fails (fd_redirects ×10). Bin dirs now use a bracket-free name.
  • $0 drive-path expectation: script_file_accepts_shell_style_drive_path lowercased the whole expected path, while the engine keeps the original case and lowercases only the drive letter. Now only the drive letter is normalized, gated on cfg(windows) (non-Windows expects the argv spelling verbatim), matching the bashdb_compat convention.
  • Missing host awk: the gawk -F escape pipeline probe is skipped when no awk is reachable from the sanitized environment; a missing host tool is not a regression.
  • Nested THIS_SH probe (scripts.rs) and the cfg(not(windows)) ash probe in compat_issue_regressions.rs also strip the host-install env.

Test plan

  • Windows, Rust 1.98, host with niu 1.3.3 installed and WINUXSH_ROOT exported, NIU_SHELL=target/debug/rubash.exe:
    • before: cli_tests 471 passed / 11 failed
    • after (rebased on current master dac428cc): 482 passed / 0 failed / 2 ignored
  • cargo fmt --check clean; non-Windows branches compile-checked by review.

- spawn every cli_tests engine process through a rubash_command() helper
  that strips WINUXSH_ROOT / __RUBASH_SHELL_ROOT, so hosts with a Winuxsh
  install root exported exercise this checkout, not the installed tree
- name fd_redirects external-fd-copy bin dirs without ThreadId Debug:
  ThreadId(N) puts brackets in a PATH entry and Windows .cmd resolution
  through such a path fails
- lowercase only the drive letter in the login-shell $0 expectation,
  matching the engine's display-path behavior and the bashdb_compat
  convention
- skip the gawk -F escape pipeline probe when no awk is reachable from
  the sanitized environment; a missing host tool is not a regression
- script_file_accepts_shell_style_drive_path: gate the drive-letter
  normalization on cfg(windows); on Linux/macOS niu is the forward-slash
  argv spelling verbatim, the unconditional [..1]/[3..] slicing turned
  /home/... into ///me/... and would fail non-Windows CI.
- scripts.rs nested THIS_SH probe now spawns through rubash_command()
  (strips host-install env) and keeps the forward-slash THIS_SH value;
  its Command import is gone.
- compat_issue_regressions ash-named probe (cfg(not(windows))) strips
  WINUXSH_ROOT/__RUBASH_SHELL_ROOT too, with a cfg-gated Command import
  so the file compiles on non-Windows hosts.
@github-actions

Copy link
Copy Markdown
Contributor

欢迎!这是你的第一个 PR 🎉 请确认已跑过本地测试套件;CI 通过后维护者会 review。

@caomengxuan666
caomengxuan666 merged commit 00a79ef into master Oct 22, 2026
8 checks passed
caomengxuan666 added a commit that referenced this pull request Oct 22, 2026
- finalize the 10-22 batch into [1.4.3]: the command-stem ASCII case
  fold (#998/#1000), the interactive ${v^^} crash fix (niubash#503),
  cli_tests isolation (#996), the no-IFS short-circuit re-land
  (#995/#1002), and the assoc/signal/test-bench perf batch
- backfill the missing [1.4.2] and [1.4.1] sections from the tag
  boundaries (the bump-only releases left them unwritten)
- PROJECT version 1.4.2 -> 1.4.3
@caomengxuan666
caomengxuan666 deleted the fix/test-isolation branch October 23, 2026 08:54
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.

2 participants