diff options
-rw-r--r-- | meta/lib/oeqa/oetest.py | 29 |
1 files changed, 21 insertions, 8 deletions
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 | |||
11 | import unittest | 11 | import unittest |
12 | import inspect | 12 | import inspect |
13 | import subprocess | 13 | import subprocess |
14 | import bb | 14 | try: |
15 | import bb | ||
16 | except ImportError: | ||
17 | pass | ||
18 | import logging | ||
15 | from oeqa.utils.decorators import LogResults, gettag | 19 | from oeqa.utils.decorators import LogResults, gettag |
16 | from sys import exc_info, exc_clear | 20 | from sys import exc_info, exc_clear |
17 | 21 | ||
22 | logger = logging.getLogger("BitBake") | ||
23 | |||
18 | def getVar(obj): | 24 | def getVar(obj): |
19 | #extend form dict, if a variable didn't exists, need find it in testcase | 25 | #extend form dict, if a variable didn't exists, need find it in testcase |
20 | class VarDict(dict): | 26 | class VarDict(dict): |
@@ -89,7 +95,7 @@ def loadTests(tc, type="runtime"): | |||
89 | suite.dependencies.append(dep_suite) | 95 | suite.dependencies.append(dep_suite) |
90 | break | 96 | break |
91 | else: | 97 | else: |
92 | bb.warn("Test %s was declared as @skipUnlessPassed('%s') but that test is either not defined or not active. Will run the test anyway." % | 98 | logger.warning("Test %s was declared as @skipUnlessPassed('%s') but that test is either not defined or not active. Will run the test anyway." % |
93 | (test, depends_on)) | 99 | (test, depends_on)) |
94 | # Use brute-force topological sort to determine ordering. Sort by | 100 | # Use brute-force topological sort to determine ordering. Sort by |
95 | # depth (higher depth = must run later), with original ordering to | 101 | # depth (higher depth = must run later), with original ordering to |
@@ -114,19 +120,26 @@ def custom_verbose(msg, *args, **kwargs): | |||
114 | _buffer += msg | 120 | _buffer += msg |
115 | else: | 121 | else: |
116 | _buffer += msg | 122 | _buffer += msg |
117 | bb.plain(_buffer.rstrip("\n"), *args, **kwargs) | 123 | try: |
124 | bb.plain(_buffer.rstrip("\n"), *args, **kwargs) | ||
125 | except NameError: | ||
126 | logger.info(_buffer.rstrip("\n"), *args, **kwargs) | ||
118 | _buffer = "" | 127 | _buffer = "" |
119 | 128 | ||
120 | def runTests(tc, type="runtime"): | 129 | def runTests(tc, type="runtime"): |
121 | 130 | ||
122 | suite = loadTests(tc, type) | 131 | suite = loadTests(tc, type) |
123 | bb.note("Test modules %s" % tc.testslist) | 132 | logger.info("Test modules %s" % tc.testslist) |
124 | if hasattr(tc, "tagexp") and tc.tagexp: | 133 | if hasattr(tc, "tagexp") and tc.tagexp: |
125 | bb.note("Filter test cases by tags: %s" % tc.tagexp) | 134 | logger.info("Filter test cases by tags: %s" % tc.tagexp) |
126 | bb.note("Found %s tests" % suite.countTestCases()) | 135 | logger.info("Found %s tests" % suite.countTestCases()) |
127 | runner = unittest.TextTestRunner(verbosity=2) | 136 | runner = unittest.TextTestRunner(verbosity=2) |
128 | if bb.msg.loggerDefaultVerbose: | 137 | try: |
129 | runner.stream.write = custom_verbose | 138 | if bb.msg.loggerDefaultVerbose: |
139 | runner.stream.write = custom_verbose | ||
140 | except NameError: | ||
141 | # Not in bb environment? | ||
142 | pass | ||
130 | result = runner.run(suite) | 143 | result = runner.run(suite) |
131 | 144 | ||
132 | return result | 145 | return result |