Browse Source
QA: Add build-time option to enable XML output from tests
QA: Add build-time option to enable XML output from tests
This allows CI tools to get machine-readable test reports. By default, this is off - when you test normally, you probably want the regular console spew. Boost tests use the in-built Boost test command line options. The Python tests take an --xml parameter and output the tests there.pull/15/head
4 changed files with 73 additions and 6 deletions
-
20CMakeModules/KiCadQABuildUtils.cmake
-
16Documentation/development/testing.md
-
8qa/CMakeLists.txt
-
35qa/test.py
@ -1,18 +1,45 @@ |
|||
import unittest |
|||
import platform |
|||
import sys |
|||
import argparse |
|||
|
|||
if platform.python_version() < '2.7': |
|||
unittest = __import__('unittest2') |
|||
else: |
|||
import unittest |
|||
|
|||
try: |
|||
import xmlrunner |
|||
have_xml = True |
|||
except ImportError: |
|||
have_xml = False |
|||
|
|||
|
|||
if __name__ == '__main__': |
|||
testsuite = unittest.TestLoader().discover('testcases',pattern="*.py") |
|||
results = unittest.TextTestRunner(verbosity=100).run(testsuite) |
|||
|
|||
parser = argparse.ArgumentParser( |
|||
description='Test suit for KiCad Python functions') |
|||
parser.add_argument('--xml', action="store", type=str, |
|||
help='Output XML test results to the given directory') |
|||
|
|||
args = parser.parse_args() |
|||
|
|||
if args.xml and not have_xml: |
|||
print("XML test reporting not available") |
|||
print("Install the xmlrunner package.") |
|||
sys.exit(2) |
|||
|
|||
testsuite = unittest.TestLoader().discover('testcases', pattern="*.py") |
|||
|
|||
if args.xml: |
|||
# Dump XML results to the right directory |
|||
runner = xmlrunner.XMLTestRunner(output=args.xml) |
|||
else: |
|||
# Use a normal text runner |
|||
runner = unittest.TextTestRunner(verbosity=100) |
|||
|
|||
results = runner.run(testsuite) |
|||
|
|||
# Return an error code if any of the testsuite tests fail |
|||
if not results.wasSuccessful(): |
|||
sys.exit(1) |
|||
|
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue