--- jsr166/src/test/tck/JSR166TestCase.java 2013/07/14 16:55:01 1.109 +++ jsr166/src/test/tck/JSR166TestCase.java 2014/05/14 21:06:38 1.115 @@ -26,6 +26,7 @@ import java.util.concurrent.atomic.Atomi import java.util.concurrent.atomic.AtomicReference; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.NANOSECONDS; +import java.util.regex.Pattern; import java.security.CodeSource; import java.security.Permission; import java.security.PermissionCollection; @@ -134,12 +135,27 @@ public class JSR166TestCase extends Test private static final int runsPerTest = Integer.getInteger("jsr166.runsPerTest", 1); + /** + * A filter for tests to run, matching strings of the form + * methodName(className), e.g. "testInvokeAll5(ForkJoinPoolTest)" + * Usefully combined with jsr166.runsPerTest. + */ + private static final Pattern methodFilter = methodFilter(); + + private static Pattern methodFilter() { + String regex = System.getProperty("jsr166.methodFilter"); + return (regex == null) ? null : Pattern.compile(regex); + } + protected void runTest() throws Throwable { - for (int i = 0; i < runsPerTest; i++) { - if (profileTests) - runTestProfiled(); - else - super.runTest(); + if (methodFilter == null + || methodFilter.matcher(toString()).find()) { + for (int i = 0; i < runsPerTest; i++) { + if (profileTests) + runTestProfiled(); + else + super.runTest(); + } } } @@ -205,12 +221,17 @@ public class JSR166TestCase extends Test } public static final double JAVA_CLASS_VERSION; + public static final String JAVA_SPECIFICATION_VERSION; static { try { JAVA_CLASS_VERSION = java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { public Double run() { return Double.valueOf(System.getProperty("java.class.version"));}}); + JAVA_SPECIFICATION_VERSION = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public String run() { + return System.getProperty("java.specification.version");}}); } catch (Throwable t) { throw new Error(t); } @@ -219,6 +240,10 @@ public class JSR166TestCase extends Test public static boolean atLeastJava6() { return JAVA_CLASS_VERSION >= 50.0; } public static boolean atLeastJava7() { return JAVA_CLASS_VERSION >= 51.0; } public static boolean atLeastJava8() { return JAVA_CLASS_VERSION >= 52.0; } + public static boolean atLeastJava9() { + // As of 2014-05, java9 still uses 52.0 class file version + return JAVA_SPECIFICATION_VERSION.startsWith("1.9"); + } /** * Collects all JSR166 unit tests as one suite. @@ -232,7 +257,6 @@ public class JSR166TestCase extends Test RecursiveTaskTest.suite(), LinkedTransferQueueTest.suite(), PhaserTest.suite(), - SplittableRandomTest.suite(), ThreadLocalRandomTest.suite(), AbstractExecutorServiceTest.suite(), AbstractQueueTest.suite(), @@ -295,19 +319,31 @@ public class JSR166TestCase extends Test // Java8+ test classes if (atLeastJava8()) { String[] java8TestClassNames = { + "Atomic8Test", "CompletableFutureTest", "ConcurrentHashMap8Test", "CountedCompleterTest", "DoubleAccumulatorTest", "DoubleAdderTest", "ForkJoinPool8Test", + "ForkJoinTask8Test", "LongAccumulatorTest", "LongAdderTest", + "SplittableRandomTest", "StampedLockTest", + "ThreadLocalRandom8Test", }; addNamedTestClasses(suite, java8TestClassNames); } + // Java9+ test classes + if (atLeastJava9()) { + String[] java9TestClassNames = { + "ThreadPoolExecutor9Test", + }; + addNamedTestClasses(suite, java9TestClassNames); + } + return suite; }