On Tue, 12 May 2026 19:11:23 GMT, Ashay Rane <[email protected]> wrote:

>> The powershell binary is required to run these tests but in the GitHub
>> workflow that runs tests (specifically, in test.yml), we reset the PATH
>> environment variable on Windows, causing the GitHub workflow to fail if
>> you run these tests.  The tests pass locally since local test runs don't
>> modify PATH.
>> 
>> To make these tests pass in GitHub workflows, this patch updates the
>> tests to refer to PowerShell using the canonical path on Windows.  See
>> https://github.com/raneashay/openjdk-jdk/actions/runs/25680763981/job/75401590988
>> for a sample workflow run of the tier2 part1 tests, which include the
>> CngCipher and DupAlias tests.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Ashay Rane has updated the pull request incrementally with two additional 
> commits since the last revision:
> 
>  - Add missing year to copyright notice.
>  - Move `powerShellPath()` to `jdk.test.lib.os.windows.FileUtils`
>    
>    This avoids having to duplicate the function in individual tests.

I realized that there are more hardcoded references to powershell:


>_ ag "powershell" test -l
test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/util/CommandOutputControlTest.java
test/jdk/tools/jpackage/windows/Win8365790Test.java
test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java
test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WinExecutableIconVerifier.java


I'm working through each of these and testing them both locally and in GitHub 
workflows so I plan to add a few more changes to this patch.

Interestingly (and just FYI), despite there being several hardcoded references 
to "cmd", those are not a problem since cmd.exe resides in the Windows\System32 
directory, and `CreateProcess()` tries a few different directories if the path 
doesn't contain a directory name (see 
[doc](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa#parameters)):

> If the file name does not contain a directory path, the system searches for 
> the executable file in the following sequence:
> 
> - The directory from which the application loaded.
> - The current directory for the parent process.
> - The 32-bit Windows system directory. Use the [GetSystemDirectoryA 
> function](https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemdirectorya)
>  function to get the path of this directory.
> The 16-bit Windows system directory. There is no function that obtains the 
> path of this directory, but it is searched. The name of this directory is 
> System.
> - The Windows directory. Use the [GetWindowsDirectoryA 
> function](https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getwindowsdirectorya)
>  to get the path of this directory.
> - The directories that are listed in the PATH environment variable. Note that 
> this function does not search the per-application path specified by the App 
> Paths registry key. To include this per-application path in the search 
> sequence, use the [ShellExecute 
> function](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/axe/shellexecute).

-------------

PR Comment: https://git.openjdk.org/jdk/pull/31127#issuecomment-4436268298

Reply via email to