changeset 22530:4ba1aa33fda4

Run all tests with SeparateClassLoaderRunner to ensure package private methods are accessible even if the truffle.jar is on bootclasspath.
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 06 Jan 2016 13:52:35 +0100
parents 2643b968c0c6
children 339966685900
files truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/BinaryConditionProfileTest.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/BranchProfileTest.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/ByteValueProfileTest.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/CountingConditionProfileTest.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/DoubleValueProfileTest.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/EqualityValueProfileTest.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/ExactClassValueProfileTest.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/FloatValueProfileTest.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/IdentityValueProfileTest.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/IntValueProfileTest.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/LazyProfileLoadingTest.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/LongValueProfileTest.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/LoopConditionProfileTest.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/PrimitiveValueProfileTest.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/SeparateClassloaderTestRunner.java
diffstat 15 files changed, 77 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/BinaryConditionProfileTest.java	Wed Jan 06 10:59:58 2016 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/BinaryConditionProfileTest.java	Wed Jan 06 13:52:35 2016 +0100
@@ -28,11 +28,10 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.theories.DataPoints;
-import org.junit.experimental.theories.Theories;
 import org.junit.experimental.theories.Theory;
 import org.junit.runner.RunWith;
 
-@RunWith(Theories.class)
+@RunWith(SeparateClassloaderTestRunner.Theories.class)
 public class BinaryConditionProfileTest {
 
     @DataPoints public static boolean[] data = new boolean[]{true, false};
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/BranchProfileTest.java	Wed Jan 06 10:59:58 2016 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/BranchProfileTest.java	Wed Jan 06 13:52:35 2016 +0100
@@ -26,7 +26,9 @@
 import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
+import org.junit.runner.RunWith;
 
+@RunWith(SeparateClassloaderTestRunner.class)
 public class BranchProfileTest {
 
     @Test
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/ByteValueProfileTest.java	Wed Jan 06 10:59:58 2016 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/ByteValueProfileTest.java	Wed Jan 06 13:52:35 2016 +0100
@@ -30,11 +30,10 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.theories.DataPoint;
-import org.junit.experimental.theories.Theories;
 import org.junit.experimental.theories.Theory;
 import org.junit.runner.RunWith;
 
-@RunWith(Theories.class)
+@RunWith(SeparateClassloaderTestRunner.Theories.class)
 public class ByteValueProfileTest {
 
     @DataPoint public static final byte VALUE0 = Byte.MIN_VALUE;
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/CountingConditionProfileTest.java	Wed Jan 06 10:59:58 2016 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/CountingConditionProfileTest.java	Wed Jan 06 13:52:35 2016 +0100
@@ -28,11 +28,10 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.theories.DataPoints;
-import org.junit.experimental.theories.Theories;
 import org.junit.experimental.theories.Theory;
 import org.junit.runner.RunWith;
 
-@RunWith(Theories.class)
+@RunWith(SeparateClassloaderTestRunner.Theories.class)
 public class CountingConditionProfileTest {
 
     @DataPoints public static boolean[] data = new boolean[]{true, false};
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/DoubleValueProfileTest.java	Wed Jan 06 10:59:58 2016 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/DoubleValueProfileTest.java	Wed Jan 06 13:52:35 2016 +0100
@@ -29,11 +29,10 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.theories.DataPoint;
-import org.junit.experimental.theories.Theories;
 import org.junit.experimental.theories.Theory;
 import org.junit.runner.RunWith;
 
-@RunWith(Theories.class)
+@RunWith(SeparateClassloaderTestRunner.Theories.class)
 public class DoubleValueProfileTest {
 
     @DataPoint public static final double VALUE0 = Double.MIN_VALUE;
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/EqualityValueProfileTest.java	Wed Jan 06 10:59:58 2016 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/EqualityValueProfileTest.java	Wed Jan 06 13:52:35 2016 +0100
@@ -30,11 +30,10 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.theories.DataPoint;
-import org.junit.experimental.theories.Theories;
 import org.junit.experimental.theories.Theory;
 import org.junit.runner.RunWith;
 
-@RunWith(Theories.class)
+@RunWith(SeparateClassloaderTestRunner.Theories.class)
 public class EqualityValueProfileTest {
 
     @DataPoint public static final String O1 = new String();
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/ExactClassValueProfileTest.java	Wed Jan 06 10:59:58 2016 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/ExactClassValueProfileTest.java	Wed Jan 06 13:52:35 2016 +0100
@@ -31,11 +31,10 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.theories.DataPoint;
-import org.junit.experimental.theories.Theories;
 import org.junit.experimental.theories.Theory;
 import org.junit.runner.RunWith;
 
-@RunWith(Theories.class)
+@RunWith(SeparateClassloaderTestRunner.Theories.class)
 public class ExactClassValueProfileTest {
 
     @DataPoint public static final String O1 = new String();
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/FloatValueProfileTest.java	Wed Jan 06 10:59:58 2016 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/FloatValueProfileTest.java	Wed Jan 06 13:52:35 2016 +0100
@@ -29,11 +29,10 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.theories.DataPoint;
-import org.junit.experimental.theories.Theories;
 import org.junit.experimental.theories.Theory;
 import org.junit.runner.RunWith;
 
-@RunWith(Theories.class)
+@RunWith(SeparateClassloaderTestRunner.Theories.class)
 public class FloatValueProfileTest {
 
     @DataPoint public static final float VALUE0 = Float.MIN_VALUE;
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/IdentityValueProfileTest.java	Wed Jan 06 10:59:58 2016 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/IdentityValueProfileTest.java	Wed Jan 06 13:52:35 2016 +0100
@@ -29,11 +29,10 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.theories.DataPoint;
-import org.junit.experimental.theories.Theories;
 import org.junit.experimental.theories.Theory;
 import org.junit.runner.RunWith;
 
-@RunWith(Theories.class)
+@RunWith(SeparateClassloaderTestRunner.Theories.class)
 public class IdentityValueProfileTest {
 
     @DataPoint public static final String O1 = new String();
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/IntValueProfileTest.java	Wed Jan 06 10:59:58 2016 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/IntValueProfileTest.java	Wed Jan 06 13:52:35 2016 +0100
@@ -29,11 +29,10 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.theories.DataPoint;
-import org.junit.experimental.theories.Theories;
 import org.junit.experimental.theories.Theory;
 import org.junit.runner.RunWith;
 
-@RunWith(Theories.class)
+@RunWith(SeparateClassloaderTestRunner.Theories.class)
 public class IntValueProfileTest {
 
     @DataPoint public static final int VALUE0 = Integer.MIN_VALUE;
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/LazyProfileLoadingTest.java	Wed Jan 06 10:59:58 2016 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/LazyProfileLoadingTest.java	Wed Jan 06 13:52:35 2016 +0100
@@ -24,16 +24,12 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.net.URLClassLoader;
 
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.junit.runners.BlockJUnit4ClassRunner;
-import org.junit.runners.model.InitializationError;
 
 import com.oracle.truffle.api.Truffle;
-import com.oracle.truffle.api.profiles.LazyProfileLoadingTest.SeparateClassloaderTestRunner;
 
 @RunWith(SeparateClassloaderTestRunner.class)
 public class LazyProfileLoadingTest {
@@ -105,34 +101,4 @@
         }
     }
 
-    public static class SeparateClassloaderTestRunner extends BlockJUnit4ClassRunner {
-
-        public SeparateClassloaderTestRunner(Class<?> clazz) throws InitializationError {
-            super(getFromTestClassloader(clazz));
-        }
-
-        private static Class<?> getFromTestClassloader(Class<?> clazz) throws InitializationError {
-            try {
-                ClassLoader testClassLoader = new TestClassLoader();
-                return Class.forName(clazz.getName(), true, testClassLoader);
-            } catch (ClassNotFoundException e) {
-                throw new InitializationError(e);
-            }
-        }
-
-        public static class TestClassLoader extends URLClassLoader {
-            public TestClassLoader() {
-                super(((URLClassLoader) getSystemClassLoader()).getURLs());
-            }
-
-            @Override
-            public Class<?> loadClass(String name) throws ClassNotFoundException {
-                if (name.startsWith(Profile.class.getPackage().getName())) {
-                    return super.findClass(name);
-                }
-                return super.loadClass(name);
-            }
-        }
-    }
-
 }
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/LongValueProfileTest.java	Wed Jan 06 10:59:58 2016 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/LongValueProfileTest.java	Wed Jan 06 13:52:35 2016 +0100
@@ -29,11 +29,10 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.theories.DataPoint;
-import org.junit.experimental.theories.Theories;
 import org.junit.experimental.theories.Theory;
 import org.junit.runner.RunWith;
 
-@RunWith(Theories.class)
+@RunWith(SeparateClassloaderTestRunner.Theories.class)
 public class LongValueProfileTest {
 
     @DataPoint public static final long VALUE0 = Long.MIN_VALUE;
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/LoopConditionProfileTest.java	Wed Jan 06 10:59:58 2016 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/LoopConditionProfileTest.java	Wed Jan 06 13:52:35 2016 +0100
@@ -28,11 +28,10 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.theories.DataPoints;
-import org.junit.experimental.theories.Theories;
 import org.junit.experimental.theories.Theory;
 import org.junit.runner.RunWith;
 
-@RunWith(Theories.class)
+@RunWith(SeparateClassloaderTestRunner.Theories.class)
 public class LoopConditionProfileTest {
 
     @DataPoints public static boolean[] data = new boolean[]{true, false};
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/PrimitiveValueProfileTest.java	Wed Jan 06 10:59:58 2016 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/PrimitiveValueProfileTest.java	Wed Jan 06 13:52:35 2016 +0100
@@ -32,12 +32,11 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.theories.DataPoint;
-import org.junit.experimental.theories.Theories;
 import org.junit.experimental.theories.Theory;
 import org.junit.runner.RunWith;
 
 @SuppressWarnings("deprecation")
-@RunWith(Theories.class)
+@RunWith(SeparateClassloaderTestRunner.Theories.class)
 public class PrimitiveValueProfileTest {
 
     @DataPoint public static final String O1 = new String();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/SeparateClassloaderTestRunner.java	Wed Jan 06 13:52:35 2016 +0100
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2013, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.api.profiles;
+
+import java.net.URLClassLoader;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.InitializationError;
+
+public final class SeparateClassloaderTestRunner extends BlockJUnit4ClassRunner {
+    public SeparateClassloaderTestRunner(Class<?> clazz) throws InitializationError {
+        super(getFromTestClassloader(clazz));
+    }
+
+    private static Class<?> getFromTestClassloader(Class<?> clazz) throws InitializationError {
+        try {
+            ClassLoader testClassLoader = new TestClassLoader();
+            return Class.forName(clazz.getName(), true, testClassLoader);
+        } catch (ClassNotFoundException e) {
+            throw new InitializationError(e);
+        }
+    }
+
+    public static final class Theories extends org.junit.experimental.theories.Theories {
+        public Theories(Class<?> clazz) throws InitializationError {
+            super(getFromTestClassloader(clazz));
+        }
+    }
+
+    private static class TestClassLoader extends URLClassLoader {
+        public TestClassLoader() {
+            super(((URLClassLoader) getSystemClassLoader()).getURLs());
+        }
+
+        @Override
+        public Class<?> loadClass(String name) throws ClassNotFoundException {
+            if (name.startsWith(Profile.class.getPackage().getName())) {
+                return super.findClass(name);
+            }
+            return super.loadClass(name);
+        }
+    }
+
+}