comparison 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
comparison
equal deleted inserted replaced
8339:338e4adafa71 8340:d9d883aeb96f
717 """ 717 """
718 718
719 matches = lambda line : len([a for a in annotations if line == a or line.startswith(a + '(')]) != 0 719 matches = lambda line : len([a for a in annotations if line == a or line.startswith(a + '(')]) != 0
720 return p.find_classes_with_matching_source_line(pkgRoot, matches, includeInnerClasses) 720 return p.find_classes_with_matching_source_line(pkgRoot, matches, includeInnerClasses)
721 721
722 def _run_tests(args, harness): 722 def _run_tests(args, harness, annotations):
723 pos = [a for a in args if a[0] != '-' and a[0] != '@' ] 723 pos = [a for a in args if a[0] != '-' and a[0] != '@' ]
724 neg = [a[1:] for a in args if a[0] == '-'] 724 neg = [a[1:] for a in args if a[0] == '-']
725 vmArgs = [a[1:] for a in args if a[0] == '@'] 725 vmArgs = [a[1:] for a in args if a[0] == '@']
726 726
727 def containsAny(c, substrings): 727 def containsAny(c, substrings):
729 if s in c: 729 if s in c:
730 return True 730 return True
731 return False 731 return False
732 732
733 for p in mx.projects(): 733 for p in mx.projects():
734 classes = _find_classes_with_annotations(p, None, ['@Test']) 734 classes = _find_classes_with_annotations(p, None, annotations)
735 735
736 if len(pos) != 0: 736 if len(pos) != 0:
737 classes = [c for c in classes if containsAny(c, pos)] 737 classes = [c for c in classes if containsAny(c, pos)]
738 if len(neg) != 0: 738 if len(neg) != 0:
739 classes = [c for c in classes if not containsAny(c, neg)] 739 classes = [c for c in classes if not containsAny(c, neg)]
740 740
741 if len(classes) != 0: 741 if len(classes) != 0:
742 mx.log('running tests in ' + p.name) 742 mx.log('running tests in ' + p.name)
743 harness(p, vmArgs, classes) 743 harness(p, vmArgs, classes)
744 744
745 def _unittest(args, annotations):
746 def harness(p, vmArgs, classes):
747 prefixArgs = ['-XX:-BootstrapGraal', '-esa', '-ea']
748 vm(prefixArgs + vmArgs + ['-cp', mx.classpath(p.name), 'org.junit.runner.JUnitCore'] + classes)
749 _run_tests(args, harness, annotations)
750
745 def unittest(args): 751 def unittest(args):
746 """run the JUnit tests 752 """run the JUnit tests (all testcases)
747 753
748 If filters are supplied, only tests whose fully qualified name 754 If filters are supplied, only tests whose fully qualified name
749 include a filter as a substring are run. Negative filters are 755 include a filter as a substring are run. Negative filters are
750 those with a '-' prefix. VM args should have a @ prefix.""" 756 those with a '-' prefix. VM args should have a @ prefix."""
751 757
752 def harness(p, vmArgs, classes): 758 _unittest(args, ['@Test', '@LongTest'])
753 prefixArgs = ['-XX:-BootstrapGraal', '-esa', '-ea'] 759
754 vm(prefixArgs + vmArgs + ['-cp', mx.classpath(p.name), 'org.junit.runner.JUnitCore'] + classes) 760 def shortunittest(args):
755 _run_tests(args, harness) 761 """run the JUnit tests (short testcases only)
762
763 If filters are supplied, only tests whose fully qualified name
764 include a filter as a substring are run. Negative filters are
765 those with a '-' prefix. VM args should have a @ prefix."""
766
767 _unittest(args, ['@Test'])
768
769 def longunittest(args):
770 """run the JUnit tests (long testcases only)
771
772 If filters are supplied, only tests whose fully qualified name
773 include a filter as a substring are run. Negative filters are
774 those with a '-' prefix. VM args should have a @ prefix."""
775
776 _unittest(args, ['@LongTest'])
756 777
757 def buildvms(args): 778 def buildvms(args):
758 """build one or more VMs in various configurations""" 779 """build one or more VMs in various configurations"""
759 780
760 parser = ArgumentParser(prog='mx buildvms'); 781 parser = ArgumentParser(prog='mx buildvms');
870 891
871 _vmbuild = 'product' 892 _vmbuild = 'product'
872 t = Task('BootstrapWithRegisterPressure:product') 893 t = Task('BootstrapWithRegisterPressure:product')
873 vm(['-G:RegisterPressure=rbx,r11,r14,xmm3,xmm11,xmm14', '-esa', '-version']) 894 vm(['-G:RegisterPressure=rbx,r11,r14,xmm3,xmm11,xmm14', '-esa', '-version'])
874 tasks.append(t.stop()) 895 tasks.append(t.stop())
875 896
876 originalVm = _vm 897 originalVm = _vm
877 _vm = 'server' # hosted mode 898 _vm = 'server' # hosted mode
878 t = Task('UnitTests:hosted-product') 899 t = Task('UnitTests:hosted-product')
879 unittest([]) 900 unittest([])
880 tasks.append(t.stop()) 901 tasks.append(t.stop())
1191 #'example': [example, '[-v] example names...'], 1212 #'example': [example, '[-v] example names...'],
1192 'gate' : [gate, '[-options]'], 1213 'gate' : [gate, '[-options]'],
1193 'gv' : [gv, ''], 1214 'gv' : [gv, ''],
1194 'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'], 1215 'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'],
1195 'unittest' : [unittest, '[filters...]'], 1216 'unittest' : [unittest, '[filters...]'],
1217 'longunittest' : [longunittest, '[filters...]'],
1218 'shortunittest' : [shortunittest, '[filters...]'],
1196 'jacocoreport' : [jacocoreport, '[output directory]'], 1219 'jacocoreport' : [jacocoreport, '[output directory]'],
1197 'site' : [site, '[-options]'], 1220 'site' : [site, '[-options]'],
1198 'vm': [vm, '[-options] class [args...]'], 1221 'vm': [vm, '[-options] class [args...]'],
1199 'vmg': [vmg, '[-options] class [args...]'], 1222 'vmg': [vmg, '[-options] class [args...]'],
1200 'vmfg': [vmfg, '[-options] class [args...]'], 1223 'vmfg': [vmfg, '[-options] class [args...]'],