Mercurial > hg > truffle
comparison mx/mx_graal.py @ 15113:4da162518b39
mx: add unittest options.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Tue, 15 Apr 2014 17:11:48 +0200 |
parents | ed1cfed14afa |
children | 2082889fc8f6 |
comparison
equal
deleted
inserted
replaced
15112:257ec29335cf | 15113:4da162518b39 |
---|---|
26 # | 26 # |
27 # ---------------------------------------------------------------------------------------------------- | 27 # ---------------------------------------------------------------------------------------------------- |
28 | 28 |
29 import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing, StringIO | 29 import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing, StringIO |
30 from os.path import join, exists, dirname, basename, getmtime | 30 from os.path import join, exists, dirname, basename, getmtime |
31 from argparse import ArgumentParser, REMAINDER | 31 from argparse import ArgumentParser, RawDescriptionHelpFormatter, REMAINDER |
32 from outputparser import OutputParser, ValuesMatcher | 32 from outputparser import OutputParser, ValuesMatcher |
33 import mx | 33 import mx |
34 import xml.dom.minidom | 34 import xml.dom.minidom |
35 import sanitycheck | 35 import sanitycheck |
36 import itertools | 36 import itertools |
898 finally: | 898 finally: |
899 if os.environ.get('MX_TESTFILE') is None: | 899 if os.environ.get('MX_TESTFILE') is None: |
900 os.remove(testfile) | 900 os.remove(testfile) |
901 | 901 |
902 _unittestHelpSuffix = """ | 902 _unittestHelpSuffix = """ |
903 Unittest options: | |
904 | |
905 --short-only run short testcases only | |
906 --long-only run long testcases only | |
907 | |
908 To avoid conflicts with VM options '--' can be used as delimiter. | |
903 | 909 |
904 If filters are supplied, only tests whose fully qualified name | 910 If filters are supplied, only tests whose fully qualified name |
905 includes a filter as a substring are run. | 911 includes a filter as a substring are run. |
906 | 912 |
907 For example, this command line: | 913 For example, this command line: |
926 """ | 932 """ |
927 | 933 |
928 def unittest(args): | 934 def unittest(args): |
929 """run the JUnit tests (all testcases){0}""" | 935 """run the JUnit tests (all testcases){0}""" |
930 | 936 |
931 _unittest(args, ['@Test', '@LongTest', '@Parameters']) | 937 parser = ArgumentParser(prog='mx unittest', |
938 description='run the JUnit tests', | |
939 add_help=False, | |
940 formatter_class=RawDescriptionHelpFormatter, | |
941 epilog=_unittestHelpSuffix, | |
942 ) | |
943 group = parser.add_mutually_exclusive_group() | |
944 group.add_argument('--short-only', action='store_true', help='run short testcases only') | |
945 group.add_argument('--long-only', action='store_true', help='run long testcases only') | |
946 | |
947 ut_args = [] | |
948 delimiter = False | |
949 # check for delimiter | |
950 while len(args) > 0: | |
951 arg = args.pop(0) | |
952 if arg == '--': | |
953 delimiter = True | |
954 break | |
955 ut_args.append(arg) | |
956 | |
957 if delimiter: | |
958 # all arguments before '--' must be recognized | |
959 parsed_args = parser.parse_args(ut_args) | |
960 else: | |
961 # parse all know arguments | |
962 parsed_args, remaining_args = parser.parse_known_args(ut_args) | |
963 args = remaining_args + args | |
964 | |
965 if parsed_args.long_only: | |
966 annotations = ['@LongTest', '@Parameters'] | |
967 elif parsed_args.short_only: | |
968 annotations = ['@Test'] | |
969 else: | |
970 annotations = ['@Test', '@LongTest', '@Parameters'] | |
971 | |
972 _unittest(args, annotations) | |
932 | 973 |
933 def shortunittest(args): | 974 def shortunittest(args): |
934 """run the JUnit tests (short testcases only){0}""" | 975 """alias for 'unittest --short-only'{0}""" |
935 | 976 |
936 _unittest(args, ['@Test']) | 977 args.insert(0, '--short-only') |
978 unittest(args) | |
937 | 979 |
938 def longunittest(args): | 980 def longunittest(args): |
939 """run the JUnit tests (long testcases only){0}""" | 981 """alias for 'unittest --long-only'{0}""" |
940 | 982 |
941 _unittest(args, ['@LongTest', '@Parameters']) | 983 args.insert(0, '--long-only') |
984 unittest(args) | |
942 | 985 |
943 def buildvms(args): | 986 def buildvms(args): |
944 """build one or more VMs in various configurations""" | 987 """build one or more VMs in various configurations""" |
945 | 988 |
946 vmsDefault = ','.join(_vmChoices.keys()) | 989 vmsDefault = ','.join(_vmChoices.keys()) |
1782 'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'], | 1825 'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'], |
1783 'specjbb2013': [specjbb2013, '[VM options] [-- [SPECjbb2013 options]]'], | 1826 'specjbb2013': [specjbb2013, '[VM options] [-- [SPECjbb2013 options]]'], |
1784 'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'], | 1827 'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'], |
1785 'gate' : [gate, '[-options]'], | 1828 'gate' : [gate, '[-options]'], |
1786 'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'], | 1829 'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'], |
1787 'unittest' : [unittest, '[VM options] [filters...]', _unittestHelpSuffix], | 1830 'unittest' : [unittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix], |
1788 'longunittest' : [longunittest, '[VM options] [filters...]', _unittestHelpSuffix], | 1831 'longunittest' : [longunittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix], |
1789 'shortunittest' : [shortunittest, '[VM options] [filters...]', _unittestHelpSuffix], | 1832 'shortunittest' : [shortunittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix], |
1790 'jacocoreport' : [jacocoreport, '[output directory]'], | 1833 'jacocoreport' : [jacocoreport, '[output directory]'], |
1791 'site' : [site, '[-options]'], | 1834 'site' : [site, '[-options]'], |
1792 'vm': [vm, '[-options] class [args...]'], | 1835 'vm': [vm, '[-options] class [args...]'], |
1793 'vmg': [vmg, '[-options] class [args...]'], | 1836 'vmg': [vmg, '[-options] class [args...]'], |
1794 'vmfg': [vmfg, '[-options] class [args...]'], | 1837 'vmfg': [vmfg, '[-options] class [args...]'], |