Mercurial > hg > graal-compiler
comparison mx/commands.py @ 8406:2bfb9644dcc2
unittest: call wrapper to avoid long command lines
on windows there's a restriction of ~32k characters for
the whole command line.
fwiw, linux/bsd have also restrictions, but it is
unlikely that we'll ever hit that (2097k characters
on my linux machine).
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Mon, 18 Mar 2013 19:18:42 +0100 |
parents | a3c30d467f96 |
children | 87346100d7a5 c3657d00e343 |
comparison
equal
deleted
inserted
replaced
8405:743d0ac1fc81 | 8406:2bfb9644dcc2 |
---|---|
25 # questions. | 25 # questions. |
26 # | 26 # |
27 # ---------------------------------------------------------------------------------------------------- | 27 # ---------------------------------------------------------------------------------------------------- |
28 | 28 |
29 import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing | 29 import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing |
30 from os.path import join, exists, dirname, basename | 30 from os.path import join, exists, dirname, basename, getmtime |
31 from argparse import ArgumentParser, REMAINDER | 31 from argparse import ArgumentParser, REMAINDER |
32 import mx | 32 import mx |
33 import sanitycheck | 33 import sanitycheck |
34 import json | 34 import json |
35 | 35 |
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, annotations): | 722 def _run_tests(args, harness, annotations, testfile): |
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): |
740 classes = [c for c in classes if not containsAny(c, neg)] | 740 classes = [c for c in classes if not containsAny(c, neg)] |
741 | 741 |
742 projectscp = mx.classpath([pcp.name for pcp in mx.projects()]) | 742 projectscp = mx.classpath([pcp.name for pcp in mx.projects()]) |
743 | 743 |
744 if len(classes) != 0: | 744 if len(classes) != 0: |
745 harness(projectscp, vmArgs, classes) | 745 f_testfile = open(testfile, 'w') |
746 for c in classes: | |
747 f_testfile.write(c + '\n') | |
748 f_testfile.close() | |
749 harness(projectscp, vmArgs) | |
746 | 750 |
747 def _unittest(args, annotations): | 751 def _unittest(args, annotations): |
748 def harness(projectscp, vmArgs, classes): | 752 mxdir = dirname(__file__) |
753 name = 'JUnitWrapper' | |
754 javaSource = join(mxdir, name + '.java') | |
755 javaClass = join(mxdir, name + '.class') | |
756 (_, testfile) = tempfile.mkstemp(".testclasses", "graal") | |
757 | |
758 def harness(projectscp, vmArgs): | |
759 if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource): | |
760 subprocess.check_call([mx.java().javac, '-cp', projectscp, '-d', mxdir, javaSource]) | |
749 prefixArgs = ['-XX:-BootstrapGraal', '-esa', '-ea'] | 761 prefixArgs = ['-XX:-BootstrapGraal', '-esa', '-ea'] |
750 vm(prefixArgs + vmArgs + ['-cp', projectscp, 'org.junit.runner.JUnitCore'] + classes) | 762 vm(prefixArgs + vmArgs + ['-cp', projectscp + ':' + mxdir, name] + [testfile]) |
751 _run_tests(args, harness, annotations) | 763 |
764 _run_tests(args, harness, annotations, testfile) | |
765 os.remove(testfile) | |
752 | 766 |
753 def unittest(args): | 767 def unittest(args): |
754 """run the JUnit tests (all testcases) | 768 """run the JUnit tests (all testcases) |
755 | 769 |
756 If filters are supplied, only tests whose fully qualified name | 770 If filters are supplied, only tests whose fully qualified name |