Skip to content

Commit 6bcbc3b

Browse files
asilichenkoRoger Riggs
authored andcommitted
8353489: Increase timeout and improve Windows compatibility in test/jdk/java/lang/ProcessBuilder/Basic.java
Reviewed-by: rriggs
1 parent 65f188f commit 6bcbc3b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

test/jdk/java/lang/ProcessBuilder/Basic.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -35,8 +35,8 @@
3535
* @requires !vm.musl
3636
* @requires vm.flagless
3737
* @library /test/lib
38-
* @run main/othervm/native/timeout=300 Basic
39-
* @run main/othervm/native/timeout=300 -Djdk.lang.Process.launchMechanism=fork Basic
38+
* @run main/othervm/native/timeout=360 Basic
39+
* @run main/othervm/native/timeout=360 -Djdk.lang.Process.launchMechanism=fork Basic
4040
* @author Martin Buchholz
4141
*/
4242

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

5757
import java.io.*;
58-
import java.lang.reflect.Field;
5958
import java.nio.charset.Charset;
6059
import java.nio.file.Files;
6160
import java.nio.file.Path;
@@ -207,7 +206,7 @@ private static void compareLinesIgnoreCase(String lines1, String lines2) {
207206

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

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

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

0 commit comments

Comments
 (0)