diff mx/commands.py @ 8340:d9d883aeb96f

unittest: seperate target `longunittest' and `shortunittest' There are some unittests which took a quite long time, e.g. Test6850611 takes about 16seconds on my machine. We want them to shift into a seperate mx target. In order to move a testcase to `longunittest' you have to replace all `@Test' with `@LongTest' in the testclass. `@Test' belongs to `shortunittest'. The target `unittest` executes both, `@Test' and `@LongTest'. Note: Mixing `@Test' and `@LongTest' in a testclass, causes that each testmethod is executed for both, `shortunittest' and `longunittest', mx targets.
author Bernhard Urban <bernhard.urban@jku.at>
date Thu, 14 Mar 2013 19:07:42 +0100
parents 3d515bfc1677
children a3c30d467f96
line wrap: on
line diff
--- a/mx/commands.py	Mon Mar 18 00:36:23 2013 +0100
+++ b/mx/commands.py	Thu Mar 14 19:07:42 2013 +0100
@@ -719,7 +719,7 @@
     matches = lambda line : len([a for a in annotations if line == a or line.startswith(a + '(')]) != 0
     return p.find_classes_with_matching_source_line(pkgRoot, matches, includeInnerClasses)
 
-def _run_tests(args, harness):
+def _run_tests(args, harness, annotations):
     pos = [a for a in args if a[0] != '-' and a[0] != '@' ]
     neg = [a[1:] for a in args if a[0] == '-']
     vmArgs = [a[1:] for a in args if a[0] == '@']
@@ -731,7 +731,7 @@
         return False
 
     for p in mx.projects():
-        classes = _find_classes_with_annotations(p, None, ['@Test'])
+        classes = _find_classes_with_annotations(p, None, annotations)
 
         if len(pos) != 0:
             classes = [c for c in classes if containsAny(c, pos)]
@@ -742,17 +742,38 @@
             mx.log('running tests in ' + p.name)
             harness(p, vmArgs, classes)
 
+def _unittest(args, annotations):
+    def harness(p, vmArgs, classes):
+        prefixArgs = ['-XX:-BootstrapGraal', '-esa', '-ea']
+        vm(prefixArgs + vmArgs + ['-cp', mx.classpath(p.name), 'org.junit.runner.JUnitCore'] + classes)
+    _run_tests(args, harness, annotations)
+
 def unittest(args):
-    """run the JUnit tests
+    """run the JUnit tests (all testcases)
 
     If filters are supplied, only tests whose fully qualified name
     include a filter as a substring are run. Negative filters are
     those with a '-' prefix. VM args should have a @ prefix."""
 
-    def harness(p, vmArgs, classes):
-        prefixArgs = ['-XX:-BootstrapGraal', '-esa', '-ea']
-        vm(prefixArgs + vmArgs + ['-cp', mx.classpath(p.name), 'org.junit.runner.JUnitCore'] + classes)
-    _run_tests(args, harness)
+    _unittest(args, ['@Test', '@LongTest'])
+
+def shortunittest(args):
+    """run the JUnit tests (short testcases only)
+
+    If filters are supplied, only tests whose fully qualified name
+    include a filter as a substring are run. Negative filters are
+    those with a '-' prefix. VM args should have a @ prefix."""
+
+    _unittest(args, ['@Test'])
+
+def longunittest(args):
+    """run the JUnit tests (long testcases only)
+
+    If filters are supplied, only tests whose fully qualified name
+    include a filter as a substring are run. Negative filters are
+    those with a '-' prefix. VM args should have a @ prefix."""
+
+    _unittest(args, ['@LongTest'])
 
 def buildvms(args):
     """build one or more VMs in various configurations"""
@@ -872,7 +893,7 @@
         t = Task('BootstrapWithRegisterPressure:product')
         vm(['-G:RegisterPressure=rbx,r11,r14,xmm3,xmm11,xmm14', '-esa', '-version'])
         tasks.append(t.stop())
-        
+
         originalVm = _vm
         _vm = 'server' # hosted mode
         t = Task('UnitTests:hosted-product')
@@ -1193,6 +1214,8 @@
         'gv' : [gv, ''],
         'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'],
         'unittest' : [unittest, '[filters...]'],
+        'longunittest' : [longunittest, '[filters...]'],
+        'shortunittest' : [shortunittest, '[filters...]'],
         'jacocoreport' : [jacocoreport, '[output directory]'],
         'site' : [site, '[-options]'],
         'vm': [vm, '[-options] class [args...]'],