diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-05-09 14:35:03 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-06-07 13:57:48 +0100 |
commit | 2df7c1f926cd8c80276752a939306222ec190924 (patch) | |
tree | 8b010d62b4db077290ec00be80c0c388bbe5ffdc /meta | |
parent | c8764f8b0043b1254594bce51ccc0a3cb0141258 (diff) | |
download | poky-2df7c1f926cd8c80276752a939306222ec190924.tar.gz |
oeqa/concurrenttest: Patch subunit module to handle classSetup failures
Currently setupClass errors were not being mapped back to the failing tests
and they were hence being marked as UNKNOWN and the test statistics were
inaccurate.
This is because whilst the errors were being encoded into the test results
stream, the decoder doesn't cope with an error outside a testStart event.
We patch in an addError handler to the outsideTest parser so that this
does get handled in a way similar to the non-concurrent case.
It would be nice if we didn't have to do this but there doesn't seem
to be any other way to fix this other than forking subunit.
We also make a minor change so another of our changes can cope with
tests without a start time.
(From OE-Core rev: 741cf82d0e7f9e797ba35157a1466fadbf74dc64)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/core/utils/concurrencytest.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/meta/lib/oeqa/core/utils/concurrencytest.py b/meta/lib/oeqa/core/utils/concurrencytest.py index e050818f0f..df8d5d0c8d 100644 --- a/meta/lib/oeqa/core/utils/concurrencytest.py +++ b/meta/lib/oeqa/core/utils/concurrencytest.py | |||
@@ -19,6 +19,7 @@ import testtools | |||
19 | import threading | 19 | import threading |
20 | import time | 20 | import time |
21 | import io | 21 | import io |
22 | import subunit | ||
22 | 23 | ||
23 | from queue import Queue | 24 | from queue import Queue |
24 | from itertools import cycle | 25 | from itertools import cycle |
@@ -51,10 +52,11 @@ class BBThreadsafeForwardingResult(ThreadsafeForwardingResult): | |||
51 | def _add_result_with_semaphore(self, method, test, *args, **kwargs): | 52 | def _add_result_with_semaphore(self, method, test, *args, **kwargs): |
52 | self.semaphore.acquire() | 53 | self.semaphore.acquire() |
53 | try: | 54 | try: |
54 | self.result.starttime[test.id()] = self._test_start.timestamp() | 55 | if self._test_start: |
55 | self.result.threadprogress[self.threadnum].append(test.id()) | 56 | self.result.starttime[test.id()] = self._test_start.timestamp() |
56 | totalprogress = sum(len(x) for x in self.result.threadprogress.values()) | 57 | self.result.threadprogress[self.threadnum].append(test.id()) |
57 | self.result.progressinfo[test.id()] = "%s: %s/%s %s/%s (%ss) (%s)" % ( | 58 | totalprogress = sum(len(x) for x in self.result.threadprogress.values()) |
59 | self.result.progressinfo[test.id()] = "%s: %s/%s %s/%s (%ss) (%s)" % ( | ||
58 | self.threadnum, | 60 | self.threadnum, |
59 | len(self.result.threadprogress[self.threadnum]), | 61 | len(self.result.threadprogress[self.threadnum]), |
60 | self.totalinprocess, | 62 | self.totalinprocess, |
@@ -67,6 +69,23 @@ class BBThreadsafeForwardingResult(ThreadsafeForwardingResult): | |||
67 | super(BBThreadsafeForwardingResult, self)._add_result_with_semaphore(method, test, *args, **kwargs) | 69 | super(BBThreadsafeForwardingResult, self)._add_result_with_semaphore(method, test, *args, **kwargs) |
68 | 70 | ||
69 | # | 71 | # |
72 | # We have to patch subunit since it doesn't understand how to handle addError | ||
73 | # outside of a running test case. This can happen if classSetUp() fails | ||
74 | # for a class of tests. This unfortunately has horrible internal knowledge. | ||
75 | # | ||
76 | def outSideTestaddError(self, offset, line): | ||
77 | """An 'error:' directive has been read.""" | ||
78 | test_name = line[offset:-1].decode('utf8') | ||
79 | self.parser._current_test = subunit.RemotedTestCase(test_name) | ||
80 | self.parser.current_test_description = test_name | ||
81 | self.parser._state = self.parser._reading_error_details | ||
82 | self.parser._reading_error_details.set_simple() | ||
83 | self.parser.subunitLineReceived(line) | ||
84 | |||
85 | subunit._OutSideTest.addError = outSideTestaddError | ||
86 | |||
87 | |||
88 | # | ||
70 | # A dummy structure to add to io.StringIO so that the .buffer object | 89 | # A dummy structure to add to io.StringIO so that the .buffer object |
71 | # is available and accepts writes. This allows unittest with buffer=True | 90 | # is available and accepts writes. This allows unittest with buffer=True |
72 | # to interact ok with subunit which wants to access sys.stdout.buffer. | 91 | # to interact ok with subunit which wants to access sys.stdout.buffer. |