Skip to content

Fix Windows Script Tests: pre-assign concatenated here-string before Set-Content - #73

Merged
yaravind merged 2 commits into
mainfrom
copilot/fix-windows-script-tests-failure
Aug 14, 2026
Merged

Fix Windows Script Tests: pre-assign concatenated here-string before Set-Content#73
yaravind merged 2 commits into
mainfrom
copilot/fix-windows-script-tests-failure

Conversation

Copilot AI commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

The "Windows Script Tests" CI job was failing with DryRun failures: 1MockRun FAILED: jenv_setup.ps1 JEnv choice resolution - A positional parameter cannot be found that accepts argument '+'.

Root Cause

PowerShell treats a here-string (@'...'@) as a single, complete token when used as a cmdlet argument. When the mock jenv.cmd was written as:

Set-Content -LiteralPath ... -Value @'
...static lines...
'@ + "  echo jdk-21.0.12.8-hotspot $mockJdkForBatch`r`n" + @'
...more static lines...
'@

PowerShell consumed the first @'...'@ as the -Value argument, then encountered + on the closing '@ line and tried to bind it as a positional argument to Set-Content — which has no such parameter. The error only surfaced on Windows because the Linux path takes the else branch (plain here-string, no concatenation).

Fix

  • scripts/windows/run_tests.ps1: Assign the concatenated content to $jenvCmdContent before passing it to Set-Content. In assignment context, + is correctly parsed as the string concatenation operator.
$jenvCmdContent = @'
...
'@ + "  echo jdk-21.0.12.8-hotspot $mockJdkForBatch`r`n" + @'
...
'@
Set-Content -LiteralPath (Join-Path $mockRoot "jenv.cmd") -Value $jenvCmdContent

…ore Set-Content call

Co-authored-by: yaravind <4484703+yaravind@users.noreply.github.com>
Co-authored-by: yaravind <4484703+yaravind@users.noreply.github.com>
@yaravind
yaravind marked this pull request as ready for review August 14, 2026 17:16
@yaravind
yaravind merged commit 85f487c into main Aug 14, 2026
2 checks passed
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