Mercurial > hg > truffle
comparison mx/commands.py @ 4587:5b04b33dac74
add jtt tests, converted from the maxine repository using ConvertJTT
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Tue, 14 Feb 2012 16:27:59 +0100 |
parents | 7e5d8d1c74a1 |
children | 6bcf713a4f41 |
comparison
equal
deleted
inserted
replaced
4586:05a6d48a6ace | 4587:5b04b33dac74 |
---|---|
315 for line in lines: | 315 for line in lines: |
316 f.write(line) | 316 f.write(line) |
317 | 317 |
318 else: | 318 else: |
319 if not exists(jdk): | 319 if not exists(jdk): |
320 mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'') | 320 mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx build ' + build + '\'') |
321 return jdk | 321 return jdk |
322 | 322 |
323 # run a command in the windows SDK Debug Shell | 323 # run a command in the windows SDK Debug Shell |
324 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo={}): | 324 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo={}): |
325 newLine = os.linesep | 325 newLine = os.linesep |
476 # containing '@Test'. These are then determined to be the classes defining | 476 # containing '@Test'. These are then determined to be the classes defining |
477 # unit tests. | 477 # unit tests. |
478 _unittests = { | 478 _unittests = { |
479 'com.oracle.max.graal.tests': ['com.oracle.max.graal.compiler.tests'], | 479 'com.oracle.max.graal.tests': ['com.oracle.max.graal.compiler.tests'], |
480 } | 480 } |
481 _jtttests = { | |
482 'com.oracle.max.graal.jtt': ['com.oracle.max.graal.jtt'], | |
483 } | |
481 | 484 |
482 def _add_test_classes(testClassList, searchDir, pkgRoot): | 485 def _add_test_classes(testClassList, searchDir, pkgRoot): |
483 pkgDecl = re.compile(r"^package\s+([a-zA-Z_][\w\.]*)\s*;$") | 486 pkgDecl = re.compile(r"^package\s+([a-zA-Z_][\w\.]*)\s*;$") |
484 for root, _, files in os.walk(searchDir): | 487 for root, _, files in os.walk(searchDir): |
485 for name in files: | 488 for name in files: |
496 if line.strip().startswith('@Test'): | 499 if line.strip().startswith('@Test'): |
497 hasTest = True | 500 hasTest = True |
498 break | 501 break |
499 if hasTest: | 502 if hasTest: |
500 assert pkg is not None | 503 assert pkg is not None |
501 testClassList.append(pkg + '.' + name[:-len('.java')]) | 504 if pkg.startswith(pkgRoot): |
505 testClassList.append(pkg + '.' + name[:-len('.java')]) | |
502 | 506 |
503 def unittest(args): | 507 def unittest(args): |
504 """run the Graal Compiler Unit Tests in the GraalVM | 508 """run the Graal Compiler Unit Tests in the GraalVM |
505 | 509 |
506 If filters are supplied, only tests whose fully qualified name | 510 If filters are supplied, only tests whose fully qualified name |
525 if len(pos) != 0: | 529 if len(pos) != 0: |
526 classes = [c for c in classes if containsAny(c, pos)] | 530 classes = [c for c in classes if containsAny(c, pos)] |
527 if len(neg) != 0: | 531 if len(neg) != 0: |
528 classes = [c for c in classes if not containsAny(c, neg)] | 532 classes = [c for c in classes if not containsAny(c, neg)] |
529 | 533 |
530 # (ds) The boot class path must be used for some reason I don't quite understand | 534 vm(['-XX:-BootstrapGraal', '-esa', '-cp', mx.classpath(proj), 'org.junit.runner.JUnitCore'] + classes) |
531 vm(['-XX:-BootstrapGraal', '-esa', '-Xbootclasspath/a:' + mx.classpath(proj), 'org.junit.runner.JUnitCore'] + classes) | 535 |
536 def jtt(args): | |
537 """run the Java Tester Tests in the GraalVM | |
538 | |
539 If filters are supplied, only tests whose fully qualified name | |
540 include a filter as a substring are run. Negative filters are | |
541 those with a '-' prefix.""" | |
542 | |
543 pos = [a for a in args if a[0] != '-'] | |
544 neg = [a[1:] for a in args if a[0] == '-'] | |
545 | |
546 def containsAny(c, substrings): | |
547 for s in substrings: | |
548 if s in c: | |
549 return True | |
550 return False | |
551 | |
552 for proj in _jtttests.iterkeys(): | |
553 p = mx.project(proj) | |
554 classes = [] | |
555 for pkg in _jtttests[proj]: | |
556 _add_test_classes(classes, join(p.dir, 'src'), pkg) | |
557 | |
558 if len(pos) != 0: | |
559 classes = [c for c in classes if containsAny(c, pos)] | |
560 if len(neg) != 0: | |
561 classes = [c for c in classes if not containsAny(c, neg)] | |
562 | |
563 vm(['-XX:-BootstrapGraal', '-XX:CompileOnly=::test', '-Xcomp', '-esa', '-cp', mx.classpath(proj), 'org.junit.runner.JUnitCore'] + classes) | |
532 | 564 |
533 def buildvms(args): | 565 def buildvms(args): |
534 """build one or more VMs in various configurations""" | 566 """build one or more VMs in various configurations""" |
535 | 567 |
536 parser = ArgumentParser(prog='mx buildvms'); | 568 parser = ArgumentParser(prog='mx buildvms'); |
624 vm(['-esa', '-version']) | 656 vm(['-esa', '-version']) |
625 tasks.append(t.stop()) | 657 tasks.append(t.stop()) |
626 | 658 |
627 t = Task('UnitTests:' + vmbuild) | 659 t = Task('UnitTests:' + vmbuild) |
628 unittest([]) | 660 unittest([]) |
661 tasks.append(t.stop()) | |
662 | |
663 t = Task('JavaTesterTests:' + vmbuild) | |
664 jtt([]) | |
629 tasks.append(t.stop()) | 665 tasks.append(t.stop()) |
630 | 666 |
631 for test in sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel=vmbuild): | 667 for test in sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel=vmbuild): |
632 t = Task(str(test) + ':' + vmbuild) | 668 t = Task(str(test) + ':' + vmbuild) |
633 if not test.test('graal'): | 669 if not test.test('graal'): |
769 'example': [example, '[-v] example names...'], | 805 'example': [example, '[-v] example names...'], |
770 'gate' : [gate, ''], | 806 'gate' : [gate, ''], |
771 'gv' : [gv, ''], | 807 'gv' : [gv, ''], |
772 'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'], | 808 'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'], |
773 'unittest' : [unittest, '[filters...]'], | 809 'unittest' : [unittest, '[filters...]'], |
810 'jtt' : [jtt, '[filters...]'], | |
774 'vm': [vm, '[-options] class [args...]'] | 811 'vm': [vm, '[-options] class [args...]'] |
775 } | 812 } |
776 | 813 |
777 if (_vmSourcesAvailable): | 814 if (_vmSourcesAvailable): |
778 mx.add_argument('--vm', action='store', dest='vm', default='graal', choices=['graal', 'server', 'client'], help='the VM to build/run (default: graal)') | 815 mx.add_argument('--vm', action='store', dest='vm', default='graal', choices=['graal', 'server', 'client'], help='the VM to build/run (default: graal)') |