changeset 10059:4dada3ec9c58

mx checkstyle command no longer exits on first error
author Doug Simon <doug.simon@oracle.com>
date Sat, 15 Jun 2013 21:27:14 +0200
parents 440661cc7908
children 193d5163a94a
files mxtool/mx.py
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mxtool/mx.py	Sat Jun 15 21:05:01 2013 +0200
+++ b/mxtool/mx.py	Sat Jun 15 21:27:14 2013 +0200
@@ -1449,7 +1449,6 @@
             log('Excluding {0} from build (Java compliance level {1} required)'.format(p.name, p.javaCompliance))
             continue
 
-
         outputDir = p.output_dir()
         if exists(outputDir):
             if args.clean:
@@ -1849,6 +1848,12 @@
    Run Checkstyle over the Java sources. Any errors or warnings
    produced by Checkstyle result in a non-zero exit code."""
 
+    parser = ArgumentParser(prog='mx checkstyle')
+
+    parser.add_argument('-f', action='store_true', dest='force', help='force checking (disables timestamp checking)')
+    args = parser.parse_args(args)
+    
+    totalErrors = 0
     for p in sorted_deps():
         if p.native:
             continue
@@ -1870,7 +1875,7 @@
             if not exists(dirname(timestampFile)):
                 os.makedirs(dirname(timestampFile))
             mustCheck = False
-            if exists(timestampFile):
+            if not args.force and exists(timestampFile):
                 timestamp = os.path.getmtime(timestampFile)
                 for f in javafilelist:
                     if os.path.getmtime(f) > timestamp:
@@ -1880,7 +1885,8 @@
                 mustCheck = True
 
             if not mustCheck:
-                log('[all Java sources in {0} already checked - skipping]'.format(sourceDir))
+                if _opts.verbose:
+                    log('[all Java sources in {0} already checked - skipping]'.format(sourceDir))
                 continue
 
             dotCheckstyleXML = xml.dom.minidom.parse(dotCheckstyle)
@@ -1940,7 +1946,7 @@
                     batch = javafilelist[:i]
                     javafilelist = javafilelist[i:]
                     try:
-                        run_java(['-Xmx1g', '-jar', library('CHECKSTYLE').get_path(True), '-f', 'xml', '-c', config, '-o', auditfileName] + batch)
+                        run_java(['-Xmx1g', '-jar', library('CHECKSTYLE').get_path(True), '-f', 'xml', '-c', config, '-o', auditfileName] + batch, nonZeroIsFatal=False)
                     finally:
                         if exists(auditfileName):
                             errors = []
@@ -1958,7 +1964,7 @@
                                 p.ParseFile(fp)
                             if len(errors) != 0:
                                 map(log, errors)
-                                return len(errors)
+                                totalErrors = totalErrors + len(errors)
                             else:
                                 if exists(timestampFile):
                                     os.utime(timestampFile, None)
@@ -1967,7 +1973,7 @@
             finally:
                 if exists(auditfileName):
                     os.unlink(auditfileName)
-    return 0
+    return totalErrors
 
 def clean(args, parser=None):
     """remove all class files, images, and executables