Skip to content

8353489: Increase timeout and improve Windows compatibility in test/jdk/java/lang/ProcessBuilder/Basic.java #23933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

asilichenko
Copy link
Contributor

@asilichenko asilichenko commented Mar 6, 2025

This PR proposes three improvements to the Basic.java test:

  1. Increase Timeout

    • The current timeout is insufficient when running the test in IntelliJ IDEA.
    • I propose increasing it by one minute.
    • The timeout value was last modified on May 13, 2010 (commit 56131863a71c) and has remained unchanged since then.
  2. Fix Incompatibility with Windows (Cygwin vs. Native)

    • One of the tests executes the echo command.
    • This works in Cygwin but fails when running the test in a pure Windows environment (e.g., IntelliJ IDEA).
    • I propose replacing echo with cmd /c echo/, which produces the same output (a single newline) in Windows, ensuring compatibility.
  3. Prevent Autorun Scripts in the cmd /c set Command

    • The test runs cmd /c set, but in Windows, this may trigger autorun scripts.
    • I propose adding the /d options to prevent autorun scripts from affecting the test results.

These changes improve test reliability and ensure compatibility across different environments.
Testing:

  • Verified that the test runs successfully in IntelliJ IDEA without timeout issues.
  • Confirmed that cmd /c echo/ produces the expected output in Windows.
  • Ensured that cmd /d /c set correctly lists environment variables without executing autorun scripts.

Detailed Description

echo

The following test fails in a clean Windows environment (e.g., when run from IntelliJ IDEA without Cygwin):

//----------------------------------------------------------------
// Test Runtime.exec(...envp...) with envstrings without any `='
//----------------------------------------------------------------

with following error:

Cannot run program "echo": CreateProcess error=2, The system cannot find the file specified

If we try to run echo as a process in Windows, for example from IntelliJ IDEA, we get the error above, because Windows does not have such an executable, but instead this is a command of the Command Processor (CMD).

The echo. command with the . works the same way as calling echo without parameters in Unix — it outputs an empty line. Was implemented using the analogous echo/ command to avoid compatibility issues.

See: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/echo

To ensure that the echo/ command is supported in Cygwin, we need to invoke it via cmd /c, because Cygwin has its own executable "echo".

cmd.exe /c set

The following test fails in a Windows environment under specific conditions:

//----------------------------------------------------------------
// Test Runtime.exec(...envp...)
// Check for sort order of environment variables on Windows.
//----------------------------------------------------------------

with following error:

>'+=+
BAZ=GORP
CONDA_BAT=C:\\.......\\miniconda3\\condabin\\conda.bat
CONDA_EXE=C:\\........\\miniconda3\\Scripts\\conda.exe
CONDA_SHLVL=0
FOO=BAR
PATH=C:\\.........\\miniconda3\\condabin;
QUUX=
SystemRoot=C:\\WINDOWS
_=_
~=~
'< not equal to '+=+
BAZ=GORP
FOO=BAR
QUUX=
SystemRoot=C:\\WINDOWS
_=_
~=~
'

Reason
In my environment, Miniconda was installed, which adds a script execution to the autorun of cmd. This script sets additional environment variables that break this test.

To reproduce this bug, you can manually add a custom script to the autorun. I have described the steps in detail in my article: AutoRun for Windows Command Processor (cmd.exe).

Changes

  • increase timeout by one minute
  • remove unused import

For Windows

  • add /d to winEnvCommand - to disable the execution of AutoRun commands
  • replace echo with cmd /c echo.

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8353489: Increase timeout and improve Windows compatibility in test/jdk/java/lang/ProcessBuilder/Basic.java (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23933/head:pull/23933
$ git checkout pull/23933

Update a local copy of the PR:
$ git checkout pull/23933
$ git pull https://git.openjdk.org/jdk.git pull/23933/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 23933

View PR using the GUI difftool:
$ git pr show -t 23933

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23933.diff

Using Webrev

Link to Webrev Comment

- remove unused import
- increase timeout by one minute

For Windows:
- add "/d" to `winEnvCommand` - to disable the execution of AutoRun commands
- replace "echo" with "cmd /c echo."
@bridgekeeper
Copy link

bridgekeeper bot commented Mar 6, 2025

👋 Welcome back asilichenko! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Mar 6, 2025

@asilichenko This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8353489: Increase timeout and improve Windows compatibility in test/jdk/java/lang/ProcessBuilder/Basic.java

Reviewed-by: rriggs

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 1038 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@RogerRiggs) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk
Copy link

openjdk bot commented Mar 6, 2025

@asilichenko The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@asilichenko asilichenko changed the title Increase Timeout and Improve Windows Compatibility in Basic.java Test 8353489: Increase Timeout and Improve Windows Compatibility in Basic.java Test Apr 2, 2025
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 2, 2025
@mlbridge
Copy link

mlbridge bot commented Apr 2, 2025

Webrevs

@asilichenko asilichenko changed the title 8353489: Increase Timeout and Improve Windows Compatibility in Basic.java Test 8353489: Increase timeout and improve Windows compatibility in test/jdk/java/lang/ProcessBuilder/Basic.java Apr 2, 2025
@bridgekeeper
Copy link

bridgekeeper bot commented Apr 3, 2025

@asilichenko This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

1 similar comment
@bridgekeeper
Copy link

bridgekeeper bot commented May 1, 2025

@asilichenko This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@asilichenko
Copy link
Contributor Author

keep-alive

Copy link
Contributor

@RogerRiggs RogerRiggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for the update.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 5, 2025
@asilichenko
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label May 5, 2025
@openjdk
Copy link

openjdk bot commented May 5, 2025

@asilichenko
Your change (at version 90752f1) is now ready to be sponsored by a Committer.

@RogerRiggs
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented May 5, 2025

Going to push as commit 6bcbc3b.
Since your change was applied there have been 1038 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 5, 2025
@openjdk openjdk bot closed this May 5, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels May 5, 2025
@openjdk
Copy link

openjdk bot commented May 5, 2025

@RogerRiggs @asilichenko Pushed as commit 6bcbc3b.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@asilichenko asilichenko deleted the fix/basic-test-for-windows branch May 5, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs [email protected] integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants