Skip to content

Define everything Refresh-Environment calls before the PSModulePath test runs it - #11194

Merged
danielhanchen merged 2 commits into
mainfrom
fix-psmodulepath-test-extraction
Sep 17, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
fix-psmodulepath-test-extraction

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

tests/studio/test_psmodulepath_normalization.ps1 fails on every Windows runner and has done since Refresh-Environment grew a conda guard.

What happens

The behavioural leg extracts Refresh-Environment from studio/setup.ps1 and invokes it. That function now calls Test-ActiveCondaEnvironment, which the test never defines, so the run dies before its assertion:

Test-ActiveCondaEnvironment:
Line |
  29 |      if (Test-ActiveCondaEnvironment) {
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The term 'Test-ActiveCondaEnvironment' is not recognized as a name of a
     | cmdlet, function, script file, or executable program.

The whole file exits 1, which takes the PSModulePath normalization unit tests step of studio-windows-update-smoke.yml with it.

Why it passes on Linux

GetEnvironmentVariables('Machine') is empty off Windows, so the body returns before reaching that branch. Windows is the only host where this leg does anything, which makes it the only host where a missing helper can show up. The Linux lane has been green over a broken test.

The fix

Compute the closure of functions Refresh-Environment reaches, from the AST, and define all of them before invoking it. A helper added to Refresh-Environment later is then pulled in automatically rather than breaking one Windows lane weeks after the fact.

Whole-line comments are dropped before scanning, since a function named in prose is not a call and pulling it in would grow the closure to satisfy a mention rather than a dependency. That is the same rule tests/python/test_windows_installer_concurrency_guard.py applies to its own extraction check.

Today the closure resolves to Test-ActiveCondaEnvironment, Get-ActiveCondaPrefixes and Test-PathUnderCondaPrefix. A check fails if it ever resolves to nothing at all, so the mechanism cannot quietly become a no-op.

No production code changes.

…est runs it

The behavioural leg extracts Refresh-Environment from studio/setup.ps1 and invokes it. It
now calls Test-ActiveCondaEnvironment, which the test never defines, so on Windows the run
dies with 'The term Test-ActiveCondaEnvironment is not recognized' and the whole file exits
1 without reaching its assertion.

It passes on Linux for a reason that hides the defect: GetEnvironmentVariables('Machine')
is empty off Windows, so the body returns before it gets that far. Windows is the only host
where this leg does anything, which makes it the only host where a missing helper shows up.

The closure is computed from the AST rather than listed, so a helper added to
Refresh-Environment later is pulled in automatically instead of breaking one Windows lane.
Whole-line comments are dropped before scanning, since a function named in prose is not a
call. It currently resolves to Test-ActiveCondaEnvironment, Get-ActiveCondaPrefixes and
Test-PathUnderCondaPrefix, and a check fails if it resolves to nothing at all.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-17T12:19:04.252720Z 68a17e0 Manual request
🔒 Security Review ✅ Completed 2026-09-17T12:19:58.737267Z 68a17e0 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: d2ae655683

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@danielhanchen
danielhanchen merged commit dc151dd into main Sep 17, 2026
2 of 29 checks passed
@danielhanchen
danielhanchen deleted the fix-psmodulepath-test-extraction branch September 17, 2026 12:17
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 68a17e060e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 68a17e060e

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…est runs it (unslothai#11194)

* Define everything Refresh-Environment calls before the PSModulePath test runs it

The behavioural leg extracts Refresh-Environment from studio/setup.ps1 and invokes it. It
now calls Test-ActiveCondaEnvironment, which the test never defines, so on Windows the run
dies with 'The term Test-ActiveCondaEnvironment is not recognized' and the whole file exits
1 without reaching its assertion.

It passes on Linux for a reason that hides the defect: GetEnvironmentVariables('Machine')
is empty off Windows, so the body returns before it gets that far. Windows is the only host
where this leg does anything, which makes it the only host where a missing helper shows up.

The closure is computed from the AST rather than listed, so a helper added to
Refresh-Environment later is pulled in automatically instead of breaking one Windows lane.
Whole-line comments are dropped before scanning, since a function named in prose is not a
call. It currently resolves to Test-ActiveCondaEnvironment, Get-ActiveCondaPrefixes and
Test-PathUnderCondaPrefix, and a check fails if it resolves to nothing at all.

* Tighten the comments on the PSModulePath closure
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.

1 participant