Mercurial > hg > truffle
comparison mx/commands.py @ 5482:9f4783c0269e
folded -G:+CheckcastCounters functionality into checkcast snippets
fixed bug in translation of @Parameter(multiple = true) parameters
modified commands.py to appease jacoco
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 06 Jun 2012 18:04:07 +0200 |
parents | f46fee826f7f |
children | d554a6709d5e |
comparison
equal
deleted
inserted
replaced
5481:e26e6dca0bcf | 5482:9f4783c0269e |
---|---|
563 if _jacoco == 'on' or _jacoco == 'append': | 563 if _jacoco == 'on' or _jacoco == 'append': |
564 jacocoagent = mx.library("JACOCOAGENT", True) | 564 jacocoagent = mx.library("JACOCOAGENT", True) |
565 # Exclude all compiler tests and snippets | 565 # Exclude all compiler tests and snippets |
566 excludes = ['com.oracle.graal.compiler.tests.*'] | 566 excludes = ['com.oracle.graal.compiler.tests.*'] |
567 for p in mx.projects(): | 567 for p in mx.projects(): |
568 for s in p.source_dirs(): | 568 _add_classes_with_annotation(excludes, p, None, '@Snippet', includeInnerClasses=True) |
569 _add_classes_with_annotation(excludes, s, None, '@Snippet') | 569 _add_classes_with_annotation(excludes, p, None, '@ClassSubstitution', includeInnerClasses=True) |
570 _add_classes_with_annotation(excludes, s, None, '@ClassSubstitution') | |
571 agentOptions = { | 570 agentOptions = { |
572 'append' : 'true' if _jacoco == 'append' else 'false', | 571 'append' : 'true' if _jacoco == 'append' else 'false', |
573 'bootclasspath' : 'true', | 572 'bootclasspath' : 'true', |
574 'includes' : 'com.oracle.*', | 573 'includes' : 'com.oracle.*', |
575 'excludes' : ':'.join(excludes) | 574 'excludes' : ':'.join(excludes) |
576 } | 575 } |
577 args = ['-javaagent:' + jacocoagent.get_path(True) + '=' + ','.join([k + '=' + v for k, v in agentOptions.items()])] + args | 576 args = ['-javaagent:' + jacocoagent.get_path(True) + '=' + ','.join([k + '=' + v for k, v in agentOptions.items()])] + args |
578 exe = join(_jdk(build), 'bin', mx.exe_suffix('java')) | 577 exe = join(_jdk(build), 'bin', mx.exe_suffix('java')) |
579 return mx.run([exe, '-' + vm] + args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout) | 578 return mx.run([exe, '-' + vm] + args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout) |
580 | 579 |
581 def _add_classes_with_annotation(classes, srcDir, pkgRoot, annotation): | 580 def _add_classes_with_annotation(classes, p, pkgRoot, annotation, includeInnerClasses=False): |
582 """ | 581 """ |
583 Scan 'srcDir' for Java source files containing a line starting with 'annotation' | 582 Scan the sources of project 'p' for Java source files containing a line starting with 'annotation' |
584 (ignoring preceding whitespace) and add the fully qualified class name | 583 (ignoring preceding whitespace) and add the fully qualified class name |
585 to 'classes' for each Java source file matched. | 584 to 'classes' for each Java source file matched. |
586 """ | 585 """ |
587 pkgDecl = re.compile(r"^package\s+([a-zA-Z_][\w\.]*)\s*;$") | 586 pkgDecl = re.compile(r"^package\s+([a-zA-Z_][\w\.]*)\s*;$") |
588 for root, _, files in os.walk(srcDir): | 587 for srcDir in p.source_dirs(): |
589 for name in files: | 588 outputDir = p.output_dir() |
590 if name.endswith('.java') and name != 'package-info.java': | 589 for root, _, files in os.walk(srcDir): |
591 hasTest = False | 590 for name in files: |
592 with open(join(root, name)) as f: | 591 if name.endswith('.java') and name != 'package-info.java': |
593 pkg = None | 592 hasTest = False |
594 for line in f: | 593 with open(join(root, name)) as f: |
595 if line.startswith("package "): | 594 pkg = None |
596 match = pkgDecl.match(line) | 595 for line in f: |
597 if match: | 596 if line.startswith("package "): |
598 pkg = match.group(1) | 597 match = pkgDecl.match(line) |
599 else: | 598 if match: |
600 if line.strip().startswith(annotation): | 599 pkg = match.group(1) |
601 hasTest = True | 600 else: |
602 break | 601 if line.strip().startswith(annotation): |
603 if hasTest: | 602 hasTest = True |
604 assert pkg is not None | 603 break |
605 if pkgRoot is None or pkg.startswith(pkgRoot): | 604 if hasTest: |
606 classes.append(pkg + '.' + name[:-len('.java')]) | 605 basename = name[:-len('.java')] |
606 assert pkg is not None | |
607 if pkgRoot is None or pkg.startswith(pkgRoot): | |
608 pkgOutputDir = join(outputDir, pkg.replace('.', os.path.sep)) | |
609 for e in os.listdir(pkgOutputDir): | |
610 if includeInnerClasses: | |
611 if e.endswith('.class') and (e.startswith(basename) or e.startswith(basename + '$')): | |
612 classes.append(pkg + '.' + e[:-len('.class')]) | |
613 elif e == basename + '.class': | |
614 classes.append(pkg + '.' + basename) | |
607 | 615 |
608 | 616 |
609 # Table of unit tests. | 617 # Table of unit tests. |
610 # Keys are project names, values are package name lists. | 618 # Keys are project names, values are package name lists. |
611 # All source files in the given (project,package) pairs are scanned for lines | 619 # All source files in the given (project,package) pairs are scanned for lines |
637 | 645 |
638 for proj in _unittests.iterkeys(): | 646 for proj in _unittests.iterkeys(): |
639 p = mx.project(proj) | 647 p = mx.project(proj) |
640 classes = [] | 648 classes = [] |
641 for pkg in _unittests[proj]: | 649 for pkg in _unittests[proj]: |
642 _add_classes_with_annotation(classes, join(p.dir, 'src'), pkg, '@Test') | 650 _add_classes_with_annotation(classes, p, pkg, '@Test') |
643 | 651 |
644 if len(pos) != 0: | 652 if len(pos) != 0: |
645 classes = [c for c in classes if containsAny(c, pos)] | 653 classes = [c for c in classes if containsAny(c, pos)] |
646 if len(neg) != 0: | 654 if len(neg) != 0: |
647 classes = [c for c in classes if not containsAny(c, neg)] | 655 classes = [c for c in classes if not containsAny(c, neg)] |
667 | 675 |
668 for proj in _jtttests.iterkeys(): | 676 for proj in _jtttests.iterkeys(): |
669 p = mx.project(proj) | 677 p = mx.project(proj) |
670 classes = [] | 678 classes = [] |
671 for pkg in _jtttests[proj]: | 679 for pkg in _jtttests[proj]: |
672 _add_classes_with_annotation(classes, join(p.dir, 'src'), pkg, '@Test') | 680 _add_classes_with_annotation(classes, p, pkg, '@Test') |
673 | 681 |
674 if len(pos) != 0: | 682 if len(pos) != 0: |
675 classes = [c for c in classes if containsAny(c, pos)] | 683 classes = [c for c in classes if containsAny(c, pos)] |
676 if len(neg) != 0: | 684 if len(neg) != 0: |
677 classes = [c for c in classes if not containsAny(c, neg)] | 685 classes = [c for c in classes if not containsAny(c, neg)] |