Skip to content

Commit f5ae66e

Browse files
committed
8353489: Increase timeout and improve Windows compatibility in test/jdk/java/lang/ProcessBuilder/Basic.java
Reviewed-by: rrich Backport-of: 6bcbc3b0a21687504b07a0a405d824a448aea872
1 parent 6b42243 commit f5ae66e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2023, 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
@@ -36,8 +36,8 @@
3636
* @requires !vm.musl
3737
* @requires vm.flagless
3838
* @library /test/lib
39-
* @run main/othervm/native/timeout=300 -Djava.security.manager=allow Basic
40-
* @run main/othervm/native/timeout=300 -Djava.security.manager=allow -Djdk.lang.Process.launchMechanism=fork Basic
39+
* @run main/othervm/native/timeout=360 -Djava.security.manager=allow Basic
40+
* @run main/othervm/native/timeout=360 -Djava.security.manager=allow -Djdk.lang.Process.launchMechanism=fork Basic
4141
* @author Martin Buchholz
4242
*/
4343

@@ -209,7 +209,7 @@ private static void compareLinesIgnoreCase(String lines1, String lines2) {
209209

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

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

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

0 commit comments

Comments
 (0)