changeset 21691:99588c43c4b8

Making TruffleTCK abstract after skipping abstract test classes in GraalJUnitCore
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 27 May 2015 11:16:01 +0200
parents e59895e16377
children c8418635b575
files graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitCore.java graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/TruffleTCK.java
diffstat 2 files changed, 12 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitCore.java	Wed May 27 10:49:06 2015 +0200
+++ b/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitCore.java	Wed May 27 11:16:01 2015 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.test;
 
 import java.io.*;
+import java.lang.reflect.Modifier;
 import java.nio.file.*;
 import java.util.*;
 
@@ -104,7 +105,10 @@
                     }
                 }
                 try {
-                    classes.add(Class.forName(each));
+                    Class<?> cls = Class.forName(each);
+                    if ((cls.getModifiers() & Modifier.ABSTRACT) == 0) {
+                        classes.add(cls);
+                    }
                 } catch (ClassNotFoundException e) {
                     system.out().println("Could not find class: " + each);
                     Description description = Description.createSuiteDescription(each);
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/TruffleTCK.java	Wed May 27 10:49:06 2015 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/TruffleTCK.java	Wed May 27 11:16:01 2015 +0200
@@ -33,10 +33,10 @@
  * requirements of the Truffle infrastructure and tooling. Subclass, implement abstract methods and
  * include in your test suite.
  */
-public class TruffleTCK { // abstract
+public abstract class TruffleTCK {
     private TruffleVM tckVM;
 
-    public TruffleTCK() { // protected
+    protected TruffleTCK() {
     }
 
     /**
@@ -50,9 +50,7 @@
      * @return initialized Truffle virtual machine
      * @throws java.lang.Exception thrown when the VM preparation fails
      */
-    protected TruffleVM prepareVM() throws Exception { // abstract
-        return null;
-    }
+    protected abstract TruffleVM prepareVM() throws Exception;
 
     /**
      * Mimetype associated with your language. The mimetype will be passed to
@@ -61,9 +59,7 @@
      *
      * @return mime type of the tested language
      */
-    protected String mimeType() { // abstract
-        return null;
-    }
+    protected abstract String mimeType();
 
     /**
      * Name of function which will return value 42 as a number. The return value of the method
@@ -72,9 +68,7 @@
      *
      * @return name of globally exported symbol
      */
-    protected String fourtyTwo() { // abstract
-        return null;
-    }
+    protected abstract String fourtyTwo();
 
     /**
      * Name of function to add two integer values together. The symbol will be invoked with two
@@ -83,9 +77,7 @@
      *
      * @return name of globally exported symbol
      */
-    protected String plusInt() {  // abstract
-        return null;
-    }
+    protected abstract String plusInt();
 
     /**
      * Return a code snippet that is invalid in your language. Its
@@ -94,9 +86,7 @@
      *
      * @return code snippet invalid in the tested language
      */
-    protected String invalidCode() { // abstract
-        return null;
-    }
+    protected abstract String invalidCode();
 
     private TruffleVM vm() throws Exception {
         if (tckVM == null) {
@@ -111,9 +101,6 @@
 
     @Test
     public void testFortyTwo() throws Exception {
-        if (getClass() == TruffleTCK.class) {
-            return;
-        }
         TruffleVM.Symbol fourtyTwo = findGlobalSymbol(fourtyTwo());
 
         Object res = fourtyTwo.invoke(null);
@@ -127,9 +114,6 @@
 
     @Test
     public void testPlusWithInts() throws Exception {
-        if (getClass() == TruffleTCK.class) {
-            return;
-        }
         Random r = new Random();
         int a = r.nextInt(100);
         int b = r.nextInt(100);
@@ -147,9 +131,6 @@
 
     @Test(expected = IOException.class)
     public void testInvalidTestMethod() throws Exception {
-        if (getClass() == TruffleTCK.class) {
-            return;
-        }
         String mime = mimeType();
         String code = invalidCode();
         Object ret = vm().eval(mime, code);