src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/GraalTest.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
33 import java.lang.reflect.Field; |
33 import java.lang.reflect.Field; |
34 import java.lang.reflect.Method; |
34 import java.lang.reflect.Method; |
35 import java.nio.file.FileVisitResult; |
35 import java.nio.file.FileVisitResult; |
36 import java.nio.file.Files; |
36 import java.nio.file.Files; |
37 import java.nio.file.Path; |
37 import java.nio.file.Path; |
|
38 import java.nio.file.Paths; |
38 import java.nio.file.SimpleFileVisitor; |
39 import java.nio.file.SimpleFileVisitor; |
39 import java.nio.file.attribute.BasicFileAttributes; |
40 import java.nio.file.attribute.BasicFileAttributes; |
|
41 import java.nio.file.attribute.FileAttribute; |
40 import java.util.ArrayList; |
42 import java.util.ArrayList; |
41 import java.util.Arrays; |
43 import java.util.Arrays; |
42 import java.util.Collection; |
44 import java.util.Collection; |
43 import java.util.Collections; |
45 import java.util.Collections; |
44 import java.util.List; |
46 import java.util.List; |
456 |
458 |
457 static { |
459 static { |
458 Runtime.getRuntime().addShutdownHook(new Thread("GlobalMetricsPrinter") { |
460 Runtime.getRuntime().addShutdownHook(new Thread("GlobalMetricsPrinter") { |
459 @Override |
461 @Override |
460 public void run() { |
462 public void run() { |
461 globalMetrics.print(new OptionValues(OptionValues.newOptionMap())); |
463 // globalMetrics.print(new OptionValues(OptionValues.newOptionMap())); |
462 } |
464 } |
463 }); |
465 }); |
464 } |
466 } |
465 private final ThreadLocal<List<DebugContext>> cachedDebugs = new ThreadLocal<>(); |
467 private final ThreadLocal<List<DebugContext>> cachedDebugs = new ThreadLocal<>(); |
466 |
468 |
504 */ |
506 */ |
505 public static TestRule createTimeoutMillis(long milliseconds) { |
507 public static TestRule createTimeoutMillis(long milliseconds) { |
506 return createTimeout(milliseconds, TimeUnit.MILLISECONDS); |
508 return createTimeout(milliseconds, TimeUnit.MILLISECONDS); |
507 } |
509 } |
508 |
510 |
|
511 public static class TemporaryDirectory implements AutoCloseable { |
|
512 |
|
513 public final Path path; |
|
514 private IOException closeException; |
|
515 |
|
516 public TemporaryDirectory(Path dir, String prefix, FileAttribute<?>... attrs) throws IOException { |
|
517 path = Files.createTempDirectory(dir == null ? Paths.get(".") : dir, prefix, attrs); |
|
518 } |
|
519 |
|
520 @Override |
|
521 public void close() { |
|
522 closeException = removeDirectory(path); |
|
523 } |
|
524 |
|
525 public IOException getCloseException() { |
|
526 return closeException; |
|
527 } |
|
528 |
|
529 @Override |
|
530 public String toString() { |
|
531 return path.toString(); |
|
532 } |
|
533 } |
|
534 |
509 /** |
535 /** |
510 * Tries to recursively remove {@code directory}. If it fails with an {@link IOException}, the |
536 * Tries to recursively remove {@code directory}. If it fails with an {@link IOException}, the |
511 * exception's {@code toString()} is printed to {@link System#err} and the exception is |
537 * exception's {@code toString()} is printed to {@link System#err} and the exception is |
512 * returned. |
538 * returned. |
513 */ |
539 */ |