Make doc-check fail the build on warnings
authorTeemu Murtola <teemu.murtola@gmail.com>
Fri, 5 Sep 2014 17:44:03 +0000 (20:44 +0300)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Fri, 5 Sep 2014 18:49:38 +0000 (20:49 +0200)
This makes it easier to run it in Jenkins, even if it makes it work
inconsistently compared to the Doxygen targets.

Change-Id: Ifc469fb598f1f3287bc1a5dded231b304023a810

docs/doxygen/CMakeLists.txt
docs/doxygen/doxygen-check.py
docs/doxygen/reporter.py

index 264f11446e7c6415dd11b88de21f8c23d47ba497..95c73442c47af349bd2f689862f8fe0d7ea9d77f 100644 (file)
@@ -128,6 +128,7 @@ if (DOXYGEN_FOUND)
             -S ${CMAKE_SOURCE_DIR} -B ${CMAKE_BINARY_DIR}
             --installed ${CMAKE_CURRENT_BINARY_DIR}/installed-headers.txt
             -l ${CMAKE_CURRENT_BINARY_DIR}/doxygen-check.log
+            --exitcode
             --ignore ${CMAKE_CURRENT_SOURCE_DIR}/suppressions.txt
             --ignore-cycles ${CMAKE_CURRENT_SOURCE_DIR}/cycle-suppressions.txt)
         add_custom_target(doc-check COMMAND ${doc_check_command}
index 50a7727d29a6b745916a82facfe8d4c7509ac2cf..db560720cc9109ece6239376730aa7376f80c7f0 100755 (executable)
@@ -354,6 +354,8 @@ def main():
                       help='Issue notes for comments ignored by Doxygen')
     parser.add_option('-q', '--quiet', action='store_true',
                       help='Do not write status messages')
+    parser.add_option('--exitcode', action='store_true',
+                      help='Return non-zero exit code if there are warnings')
     options, args = parser.parse_args()
 
     installedlist = []
@@ -401,4 +403,7 @@ def main():
     reporter.report_unused_filters()
     reporter.close_log()
 
+    if options.exitcode and reporter.had_warnings():
+        sys.exit(1)
+
 main()
index 9be3cdae66df5993a88f5d36ec25b3abcd7d1940..14e2bfbd88ef5bb55f806a5ceb1c90cc34b91b73 100644 (file)
@@ -165,6 +165,7 @@ class Reporter(object):
         self._messages = []
         self._filters = []
         self._quiet = quiet
+        self._had_warnings = False
 
     def _write(self, message):
         """Implement actual message writing."""
@@ -178,6 +179,7 @@ class Reporter(object):
         sys.stderr.write(wholemsg)
         if self._logfp:
             self._logfp.write(wholemsg)
+        self._had_warnings = True
 
     def _report(self, message):
         """Handle a single reporter message."""
@@ -215,6 +217,10 @@ class Reporter(object):
                 text = 'warning: unused filter: ' + filterobj.get_text()
                 self._write(Message(text))
 
+    def had_warnings(self):
+        """Return true if any warnings have been reported."""
+        return self._had_warnings
+
     def close_log(self):
         """Close the log file if one exists."""
         assert not self._messages