Mercurial > hg > truffle
diff 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 |
line wrap: on
line diff
--- a/mx/commands.py Tue Jun 05 21:43:42 2012 +0200 +++ b/mx/commands.py Wed Jun 06 18:04:07 2012 +0200 @@ -565,9 +565,8 @@ # Exclude all compiler tests and snippets excludes = ['com.oracle.graal.compiler.tests.*'] for p in mx.projects(): - for s in p.source_dirs(): - _add_classes_with_annotation(excludes, s, None, '@Snippet') - _add_classes_with_annotation(excludes, s, None, '@ClassSubstitution') + _add_classes_with_annotation(excludes, p, None, '@Snippet', includeInnerClasses=True) + _add_classes_with_annotation(excludes, p, None, '@ClassSubstitution', includeInnerClasses=True) agentOptions = { 'append' : 'true' if _jacoco == 'append' else 'false', 'bootclasspath' : 'true', @@ -578,32 +577,41 @@ exe = join(_jdk(build), 'bin', mx.exe_suffix('java')) return mx.run([exe, '-' + vm] + args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout) -def _add_classes_with_annotation(classes, srcDir, pkgRoot, annotation): +def _add_classes_with_annotation(classes, p, pkgRoot, annotation, includeInnerClasses=False): """ - Scan 'srcDir' for Java source files containing a line starting with 'annotation' + Scan the sources of project 'p' for Java source files containing a line starting with 'annotation' (ignoring preceding whitespace) and add the fully qualified class name to 'classes' for each Java source file matched. """ pkgDecl = re.compile(r"^package\s+([a-zA-Z_][\w\.]*)\s*;$") - for root, _, files in os.walk(srcDir): - for name in files: - if name.endswith('.java') and name != 'package-info.java': - hasTest = False - with open(join(root, name)) as f: - pkg = None - for line in f: - if line.startswith("package "): - match = pkgDecl.match(line) - if match: - pkg = match.group(1) - else: - if line.strip().startswith(annotation): - hasTest = True - break - if hasTest: - assert pkg is not None - if pkgRoot is None or pkg.startswith(pkgRoot): - classes.append(pkg + '.' + name[:-len('.java')]) + for srcDir in p.source_dirs(): + outputDir = p.output_dir() + for root, _, files in os.walk(srcDir): + for name in files: + if name.endswith('.java') and name != 'package-info.java': + hasTest = False + with open(join(root, name)) as f: + pkg = None + for line in f: + if line.startswith("package "): + match = pkgDecl.match(line) + if match: + pkg = match.group(1) + else: + if line.strip().startswith(annotation): + hasTest = True + break + if hasTest: + basename = name[:-len('.java')] + assert pkg is not None + if pkgRoot is None or pkg.startswith(pkgRoot): + pkgOutputDir = join(outputDir, pkg.replace('.', os.path.sep)) + for e in os.listdir(pkgOutputDir): + if includeInnerClasses: + if e.endswith('.class') and (e.startswith(basename) or e.startswith(basename + '$')): + classes.append(pkg + '.' + e[:-len('.class')]) + elif e == basename + '.class': + classes.append(pkg + '.' + basename) # Table of unit tests. @@ -639,7 +647,7 @@ p = mx.project(proj) classes = [] for pkg in _unittests[proj]: - _add_classes_with_annotation(classes, join(p.dir, 'src'), pkg, '@Test') + _add_classes_with_annotation(classes, p, pkg, '@Test') if len(pos) != 0: classes = [c for c in classes if containsAny(c, pos)] @@ -669,7 +677,7 @@ p = mx.project(proj) classes = [] for pkg in _jtttests[proj]: - _add_classes_with_annotation(classes, join(p.dir, 'src'), pkg, '@Test') + _add_classes_with_annotation(classes, p, pkg, '@Test') if len(pos) != 0: classes = [c for c in classes if containsAny(c, pos)]