summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/oe-selftest33
1 files changed, 30 insertions, 3 deletions
diff --git a/scripts/oe-selftest b/scripts/oe-selftest
index 303b1d52ea..3188a410cb 100755
--- a/scripts/oe-selftest
+++ b/scripts/oe-selftest
@@ -48,8 +48,19 @@ import oeqa.utils.ftools as ftools
from oeqa.utils.commands import runCmd, get_bb_var, get_test_layer
from oeqa.selftest.base import oeSelfTest, get_available_machines
+try:
+ import xmlrunner
+ from xmlrunner.result import _XMLTestResult as TestResult
+ from xmlrunner import XMLTestRunner as _TestRunner
+except ImportError:
+ # use the base runner instead
+ from unittest import TextTestResult as TestResult
+ from unittest import TextTestRunner as _TestRunner
+
+log_prefix = "oe-selftest-" + t.strftime("%Y-%m-%d_%H:%M:%S")
+
def logger_create():
- log_file = "oe-selftest-" + t.strftime("%Y-%m-%d_%H:%M:%S") + ".log"
+ log_file = log_prefix + ".log"
if os.path.exists("oe-selftest.log"): os.remove("oe-selftest.log")
os.symlink(log_file, "oe-selftest.log")
@@ -520,7 +531,8 @@ def main():
suite = unittest.TestSuite()
loader = unittest.TestLoader()
loader.sortTestMethodsUsing = None
- runner = unittest.TextTestRunner(verbosity=2, resultclass=buildResultClass(args))
+ runner = TestRunner(verbosity=2,
+ resultclass=buildResultClass(args))
# we need to do this here, otherwise just loading the tests
# will take 2 minutes (bitbake -e calls)
oeSelfTest.testlayer_path = get_test_layer()
@@ -561,7 +573,7 @@ def buildResultClass(args):
"""Build a Result Class to use in the testcase execution"""
import site
- class StampedResult(unittest.TextTestResult):
+ class StampedResult(TestResult):
"""
Custom TestResult that prints the time when a test starts. As oe-selftest
can take a long time (ie a few hours) to run, timestamps help us understand
@@ -631,6 +643,21 @@ def buildResultClass(args):
return StampedResult
+class TestRunner(_TestRunner):
+ """Test runner class aware of exporting tests."""
+ def __init__(self, *args, **kwargs):
+ try:
+ exportdir = os.path.join(os.getcwd(), log_prefix)
+ kwargsx = dict(**kwargs)
+ # argument specific to XMLTestRunner, if adding a new runner then
+ # also add logic to use other runner's args.
+ kwargsx['output'] = exportdir
+ kwargsx['descriptions'] = False
+ # done for the case where telling the runner where to export
+ super(TestRunner, self).__init__(*args, **kwargsx)
+ except TypeError:
+ log.info("test runner init'ed like unittest")
+ super(TestRunner, self).__init__(*args, **kwargs)
if __name__ == "__main__":
try: