Commit 5a8e1f3f authored by Michael Achenbach's avatar Michael Achenbach Committed by Commit Bot

[test] Make coverage in test-runner tests work with multiprocessing

This replaces multiprocessing with threading in tests to make python
coverage work.

TBR=sergiyb@chromium.org

Bug: v8:6917
Change-Id: Idff763dfefa4a7fc782133d94089b3a5b00a194d
Reviewed-on: https://chromium-review.googlesource.com/844735Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50344}
parent 60bc8c07
......@@ -8,6 +8,21 @@ from multiprocessing import Event, Process, Queue
import traceback
def setup_testing():
"""For testing only: Use threading under the hood instead of multiprocessing
to make coverage work.
"""
global Queue
global Event
global Process
del Queue
del Event
del Process
from Queue import Queue
from threading import Event
from threading import Thread as Process
class NormalResult():
def __init__(self, result):
self.result = result
......
......@@ -122,14 +122,12 @@ class SystemTest(unittest.TestCase):
try:
import coverage
if int(coverage.__version__.split('.')[0]) < 4:
# First coverage 4.0 can deal with multiprocessing.
cls._cov = None
print 'Python coverage version >= 4 required.'
raise ImportError()
cls._cov = coverage.Coverage(
source=([os.path.join(TOOLS_ROOT, 'testrunner')]),
omit=['*unittest*', '*__init__.py'],
concurrency='multiprocessing',
)
cls._cov.exclude('raise NotImplementedError')
cls._cov.exclude('if __name__ == .__main__.:')
......@@ -145,12 +143,13 @@ class SystemTest(unittest.TestCase):
sys.path.append(TOOLS_ROOT)
global standard_runner
from testrunner import standard_runner
from testrunner.local import pool
pool.setup_testing()
@classmethod
def tearDownClass(cls):
if cls._cov:
cls._cov.stop()
cls._cov.combine()
print ''
print cls._cov.report(show_missing=True)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment