← Back to team overview

kicad-developers team mailing list archive

[PATCH] Proper python qa exit code

 

Hello

Some background info:
I was allowed by Ajo to play around on the Jenkins build server [1] to
add automatic building of the doxygen documatation for the purpose of
having it online and always up to date. I have dumped the links to
theese three documentaions, the doxygen-docs, dev-docs and
doxygen-python make targets on [2] under the "Developer documentation"
section. That is probably not the best place to put them, but none the
less where they are linked right now. I talked with Ajo about copying
them to somewhere on dev.kicad-pcb.org to get a shorter and easier to
remember URL.

Now regarding the patch:
After I got familiar with Jenkins I also made it actually build the
whole kicad, not just _pcbnew as the kicad-qa job did. In that process
I found that the python qa test script did not return anything if it
actually found errors in the unittests, which means that the Jenkins
server did not know it failed -- hence no warning to the devs. To fix
this I have made the attached patch, which catches the number of
errors from the unittest and if there are errors returns the exit code
1, which will make Jenkins notice that the build failed. The error
that was fixed in [5214] is not detected by Jenkins without this
patch. So the according patch:

Adds exit code to the qa test.py script if there are errors found in
the qa unittests.

Regards
Nick Østergaard

[1] http://ci.kicad-pcb.org/
[2] http://www.kicad-pcb.org/display/KICAD/KiCad+Documentation
[5214] http://bazaar.launchpad.net/~kicad-product-committers/kicad/product/revision/5214
=== modified file 'qa/test.py'
--- qa/test.py	2013-09-21 22:34:15 +0000
+++ qa/test.py	2014-10-22 17:30:42 +0000
@@ -1,5 +1,6 @@
 import unittest
 import platform
+import sys
 
 if platform.python_version() < '2.7':
     unittest = __import__('unittest2')
@@ -8,6 +9,7 @@
 
 if __name__ == '__main__':
     testsuite = unittest.TestLoader().discover('testcases',pattern="*.py")
-    unittest.TextTestRunner(verbosity=100).run(testsuite)
+    results = unittest.TextTestRunner(verbosity=100).run(testsuite)
+    if len(results.errors) > 0: sys.exit(1)
 
 


Follow ups