Mercurial > hg > truffle
comparison mx/commands.py @ 11777:f3e5cbd1efae
move pylint to mxtool
author | Mick Jordan <mick.jordan@oracle.com> |
---|---|
date | Tue, 24 Sep 2013 21:36:46 -0700 |
parents | 4ac92e735a16 |
children | a2958b7bf83f |
comparison
equal
deleted
inserted
replaced
11774:f6eb4866d558 | 11777:f3e5cbd1efae |
---|---|
440 stdin.write('exit' + newLine) | 440 stdin.write('exit' + newLine) |
441 if logFile: | 441 if logFile: |
442 log.close() | 442 log.close() |
443 return ret | 443 return ret |
444 | 444 |
445 def pylint(args): | |
446 """run pylint (if available) over Python source files""" | |
447 rcfile = join(_graal_home, 'mx', '.pylintrc') | |
448 if not exists(rcfile): | |
449 mx.log('pylint configuration file does not exist: ' + rcfile) | |
450 return | |
451 | |
452 try: | |
453 output = subprocess.check_output(['pylint', '--version'], stderr=subprocess.STDOUT) | |
454 m = re.match(r'.*pylint (\d+)\.(\d+)\.(\d+).*', output, re.DOTALL) | |
455 if not m: | |
456 mx.log('could not determine pylint version from ' + output) | |
457 return | |
458 major, minor, micro = (int(m.group(1)), int(m.group(2)), int(m.group(3))) | |
459 if major < 1: | |
460 mx.log('require pylint version >= 1 (got {0}.{1}.{2})'.format(major, minor, micro)) | |
461 return | |
462 except BaseException: | |
463 mx.log('pylint is not available') | |
464 return | |
465 | |
466 | |
467 env = os.environ.copy() | |
468 env['PYTHONPATH'] = dirname(mx.__file__) | |
469 | |
470 versioned = subprocess.check_output(['hg', 'locate', '-f'], stderr=subprocess.STDOUT).split(os.linesep) | |
471 for f in versioned: | |
472 if f.endswith('.py'): | |
473 pyfile = f | |
474 mx.log('Running pylint on ' + pyfile + '...') | |
475 mx.run(['pylint', '--reports=n', '--rcfile=' + rcfile, pyfile], env=env) | |
476 | |
477 def jdkhome(vm=None): | 445 def jdkhome(vm=None): |
478 """return the JDK directory selected for the 'vm' command""" | 446 """return the JDK directory selected for the 'vm' command""" |
479 build = _vmbuild if _vmSourcesAvailable else 'product' | 447 build = _vmbuild if _vmSourcesAvailable else 'product' |
480 return _jdk(build, installGraalJar=False) | 448 return _jdk(build, installGraalJar=False) |
481 | 449 |
801 for t in tests: | 769 for t in tests: |
802 if t.startswith('-'): | 770 if t.startswith('-'): |
803 mx.abort('VM option ' + t + ' must precede ' + tests[0]) | 771 mx.abort('VM option ' + t + ' must precede ' + tests[0]) |
804 | 772 |
805 candidates = [] | 773 candidates = [] |
806 for p in mx.projects(): | 774 for p in mx.projects_opt_limit_to_suites(): |
807 if mx.java().javaCompliance < p.javaCompliance: | 775 if mx.java().javaCompliance < p.javaCompliance: |
808 continue | 776 continue |
809 candidates += _find_classes_with_annotations(p, None, annotations).keys() | 777 candidates += _find_classes_with_annotations(p, None, annotations).keys() |
810 | 778 |
811 classes = [] | 779 classes = [] |
819 found = True | 787 found = True |
820 classes.append(c) | 788 classes.append(c) |
821 if not found: | 789 if not found: |
822 mx.log('warning: no tests matched by substring "' + t) | 790 mx.log('warning: no tests matched by substring "' + t) |
823 | 791 |
824 projectscp = mx.classpath([pcp.name for pcp in mx.projects() if pcp.javaCompliance <= mx.java().javaCompliance]) | 792 projectscp = mx.classpath([pcp.name for pcp in mx.projects_opt_limit_to_suites() if pcp.javaCompliance <= mx.java().javaCompliance]) |
825 | 793 |
826 if len(classes) != 0: | 794 if len(classes) != 0: |
827 f_testfile = open(testfile, 'w') | 795 f_testfile = open(testfile, 'w') |
828 for c in classes: | 796 for c in classes: |
829 f_testfile.write(c + '\n') | 797 f_testfile.write(c + '\n') |
1055 tasks = [] | 1023 tasks = [] |
1056 total = Task('Gate') | 1024 total = Task('Gate') |
1057 try: | 1025 try: |
1058 | 1026 |
1059 t = Task('Pylint') | 1027 t = Task('Pylint') |
1060 pylint([]) | 1028 mx.pylint([]) |
1061 tasks.append(t.stop()) | 1029 tasks.append(t.stop()) |
1062 | 1030 |
1063 t = Task('Clean') | 1031 t = Task('Clean') |
1064 cleanArgs = [] | 1032 cleanArgs = [] |
1065 if not args.cleanNative: | 1033 if not args.cleanNative: |
1374 'clean': [clean, ''], | 1342 'clean': [clean, ''], |
1375 'hsdis': [hsdis, '[att]'], | 1343 'hsdis': [hsdis, '[att]'], |
1376 'hcfdis': [hcfdis, ''], | 1344 'hcfdis': [hcfdis, ''], |
1377 'igv' : [igv, ''], | 1345 'igv' : [igv, ''], |
1378 'jdkhome': [print_jdkhome, ''], | 1346 'jdkhome': [print_jdkhome, ''], |
1379 'pylint': [pylint, ''], | |
1380 'dacapo': [dacapo, '[VM options] benchmarks...|"all" [DaCapo options]'], | 1347 'dacapo': [dacapo, '[VM options] benchmarks...|"all" [DaCapo options]'], |
1381 'scaladacapo': [scaladacapo, '[VM options] benchmarks...|"all" [Scala DaCapo options]'], | 1348 'scaladacapo': [scaladacapo, '[VM options] benchmarks...|"all" [Scala DaCapo options]'], |
1382 'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'], | 1349 'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'], |
1383 'specjbb2013': [specjbb2013, '[VM options] [-- [SPECjbb2013 options]]'], | 1350 'specjbb2013': [specjbb2013, '[VM options] [-- [SPECjbb2013 options]]'], |
1384 'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'], | 1351 'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'], |