8200706: Better cleanup for open/test/jdk/java/lang/ProcessBuilder/DestroyTest.java
authorrriggs
Fri, 06 Apr 2018 12:49:23 -0400
changeset 49544 d958597c7908
parent 49543 2d5d75263e77
child 49545 5556e9c1e681
child 56398 9d3b0eb749a9
8200706: Better cleanup for open/test/jdk/java/lang/ProcessBuilder/DestroyTest.java Reviewed-by: psandoz, lancea
test/jdk/java/lang/ProcessBuilder/DestroyTest.java
--- a/test/jdk/java/lang/ProcessBuilder/DestroyTest.java	Fri Apr 06 09:15:09 2018 -0400
+++ b/test/jdk/java/lang/ProcessBuilder/DestroyTest.java	Fri Apr 06 12:49:23 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, 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
@@ -145,18 +145,16 @@
         String osName = System.getProperty("os.name");
         if (osName.startsWith("Windows")) {
             return new WindowsTest();
-        } else if (osName.startsWith("Linux") == true) {
-            return new UnixTest(
-                File.createTempFile("ProcessTrap-", ".sh",null));
-        } else if (osName.startsWith("Mac OS")) {
-            return new MacTest(
-                File.createTempFile("ProcessTrap-", ".sh",null));
-        } else if (osName.equals("SunOS")) {
-            return new UnixTest(
-                File.createTempFile("ProcessTrap-", ".sh",null));
-        } else if (osName.equals("AIX")) {
-            return new UnixTest(
-                File.createTempFile("ProcessTrap-", ".sh",null));
+        } else {
+            File userDir = new File(System.getProperty("user.dir", "."));
+            File tempFile = File.createTempFile("ProcessTrap-", ".sh", userDir);
+            if (osName.startsWith("Linux") == true
+                    || osName.equals("SunOS")
+                    || osName.equals("AIX")) {
+                return new UnixTest(tempFile);
+            } else if (osName.startsWith("Mac OS")) {
+                return new MacTest(tempFile);
+            }
         }
         return null;
     }