From f1e7fb0856b2f1d403784d11332a5df9bccc74f5 Mon Sep 17 00:00:00 2001 From: Lucian Musat Date: Wed, 23 Sep 2015 18:40:25 +0300 Subject: oeqa/oetest: Remove bb as requirement for oetest. In order for the test export runner to work oetest needs to be separated from bitbake environment. There is no need to use bb import here so we can use a logger instead. (From OE-Core rev: 22bd8a600823306d7c5965a9a69b8e8888993513) Signed-off-by: Lucian Musat Signed-off-by: Richard Purdie --- meta/lib/oeqa/oetest.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'meta/lib/oeqa') diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py index 3816c1ae9b..0be61c2f0a 100644 --- a/meta/lib/oeqa/oetest.py +++ b/meta/lib/oeqa/oetest.py @@ -11,10 +11,16 @@ import os, re, mmap import unittest import inspect import subprocess -import bb +try: + import bb +except ImportError: + pass +import logging from oeqa.utils.decorators import LogResults, gettag from sys import exc_info, exc_clear +logger = logging.getLogger("BitBake") + def getVar(obj): #extend form dict, if a variable didn't exists, need find it in testcase class VarDict(dict): @@ -89,7 +95,7 @@ def loadTests(tc, type="runtime"): suite.dependencies.append(dep_suite) break else: - bb.warn("Test %s was declared as @skipUnlessPassed('%s') but that test is either not defined or not active. Will run the test anyway." % + logger.warning("Test %s was declared as @skipUnlessPassed('%s') but that test is either not defined or not active. Will run the test anyway." % (test, depends_on)) # Use brute-force topological sort to determine ordering. Sort by # depth (higher depth = must run later), with original ordering to @@ -114,19 +120,26 @@ def custom_verbose(msg, *args, **kwargs): _buffer += msg else: _buffer += msg - bb.plain(_buffer.rstrip("\n"), *args, **kwargs) + try: + bb.plain(_buffer.rstrip("\n"), *args, **kwargs) + except NameError: + logger.info(_buffer.rstrip("\n"), *args, **kwargs) _buffer = "" def runTests(tc, type="runtime"): suite = loadTests(tc, type) - bb.note("Test modules %s" % tc.testslist) + logger.info("Test modules %s" % tc.testslist) if hasattr(tc, "tagexp") and tc.tagexp: - bb.note("Filter test cases by tags: %s" % tc.tagexp) - bb.note("Found %s tests" % suite.countTestCases()) + logger.info("Filter test cases by tags: %s" % tc.tagexp) + logger.info("Found %s tests" % suite.countTestCases()) runner = unittest.TextTestRunner(verbosity=2) - if bb.msg.loggerDefaultVerbose: - runner.stream.write = custom_verbose + try: + if bb.msg.loggerDefaultVerbose: + runner.stream.write = custom_verbose + except NameError: + # Not in bb environment? + pass result = runner.run(suite) return result -- cgit v1.2.3-54-g00ecf