src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/DumpPathTest.java
changeset 58299 6df94ce3ab2f
parent 57537 ecc6e394475f
child 58679 9c3209ff7550
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/DumpPathTest.java	Tue Sep 24 08:54:08 2019 -0700
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/DumpPathTest.java	Tue Sep 24 12:47:15 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, 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
@@ -28,6 +28,7 @@
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.Paths;
 
 import jdk.internal.vm.compiler.collections.EconomicMap;
 import org.graalvm.compiler.debug.DebugOptions;
@@ -49,22 +50,20 @@
     @Test
     public void testDump() throws IOException {
         assumeManagementLibraryIsLoadable();
-        Path dumpDirectoryPath = Files.createTempDirectory("DumpPathTest");
-        String[] extensions = new String[]{".cfg", ".bgv", ".graph-strings"};
-        EconomicMap<OptionKey<?>, Object> overrides = OptionValues.newOptionMap();
-        overrides.put(DebugOptions.DumpPath, dumpDirectoryPath.toString());
-        overrides.put(DebugOptions.PrintCFG, true);
-        overrides.put(DebugOptions.PrintGraph, PrintGraphTarget.File);
-        overrides.put(DebugOptions.PrintCanonicalGraphStrings, true);
-        overrides.put(DebugOptions.Dump, "*");
+        try (TemporaryDirectory temp = new TemporaryDirectory(Paths.get("."), "DumpPathTest")) {
+            String[] extensions = new String[]{".cfg", ".bgv", ".graph-strings"};
+            EconomicMap<OptionKey<?>, Object> overrides = OptionValues.newOptionMap();
+            overrides.put(DebugOptions.DumpPath, temp.toString());
+            overrides.put(DebugOptions.PrintCFG, true);
+            overrides.put(DebugOptions.PrintGraph, PrintGraphTarget.File);
+            overrides.put(DebugOptions.PrintCanonicalGraphStrings, true);
+            overrides.put(DebugOptions.Dump, "*");
 
-        // Generate dump files.
-        test(new OptionValues(getInitialOptions(), overrides), "snippet");
-        // Check that IGV files got created, in the right place.
-        checkForFiles(dumpDirectoryPath, extensions);
-
-        // Clean up the generated files.
-        removeDirectory(dumpDirectoryPath);
+            // Generate dump files.
+            test(new OptionValues(getInitialOptions(), overrides), "snippet");
+            // Check that IGV files got created, in the right place.
+            checkForFiles(temp.path, extensions);
+        }
     }
 
     /**