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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions test/jdk/java/lang/ProcessBuilder/Basic.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -35,8 +35,8 @@
* @requires !vm.musl
* @requires vm.flagless
* @library /test/lib
* @run main/othervm/native/timeout=300 Basic
* @run main/othervm/native/timeout=300 -Djdk.lang.Process.launchMechanism=fork Basic
* @run main/othervm/native/timeout=360 Basic
* @run main/othervm/native/timeout=360 -Djdk.lang.Process.launchMechanism=fork Basic
* @author Martin Buchholz
*/

Expand All @@ -55,7 +55,6 @@
import static java.lang.ProcessBuilder.Redirect.*;

import java.io.*;
import java.lang.reflect.Field;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -207,7 +206,7 @@ private static void compareLinesIgnoreCase(String lines1, String lines2) {

private static final Runtime runtime = Runtime.getRuntime();

private static final String[] winEnvCommand = {"cmd.exe", "/c", "set"};
private static final String[] winEnvCommand = {"cmd.exe", "/d", "/c", "set"};

private static String winEnvFilter(String env) {
return env.replaceAll("\r", "")
Expand Down Expand Up @@ -1841,7 +1840,9 @@ public void doIt(Map<String,String> environ) {
// Test Runtime.exec(...envp...) with envstrings without any `='
//----------------------------------------------------------------
try {
String[] cmdp = {"echo"};
// In Windows CMD (`cmd.exe`), `echo/` outputs a newline (i.e., an empty line).
// Wrapping it with `cmd.exe /c` ensures compatibility in both native Windows and Cygwin environments.
String[] cmdp = Windows.is() ? new String[]{"cmd.exe", "/c", "echo/"} : new String[]{"echo"};
String[] envp = {"Hello", "World"}; // Yuck!
Process p = Runtime.getRuntime().exec(cmdp, envp);
equal(commandOutput(p), "\n");
Expand Down