mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 10:13:19 +02:00
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.
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
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__':
|
|
|
|
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)
|