Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: scripts/slave/unittests/expect_tests/cover.py

Issue 225633007: Upgrade to coverage 3.7.1 and have it auto-build itself on first use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: sigh our imports are a mess Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « scripts/slave/unittests/__init__.py ('k') | scripts/slave/unittests/recipe_configs_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from cStringIO import StringIO 5 from cStringIO import StringIO
6 6
7 try: 7 import test_env # pylint: disable=W0611
8 import coverage
9 coverage_version = coverage.__version__
10 except ImportError:
11 coverage = None
12 coverage_version = None
13 8
14 from distutils.version import StrictVersion 9 import coverage
15
16 if (not coverage or
17 not hasattr(coverage.collector, 'CTracer') or
18 not coverage.collector.CTracer or
19 StrictVersion(coverage_version) < StrictVersion('3.7')):
20 raise ImportError(
21 'This test requires natively-installed python-coverage (>=3.7). '
22 'Current is %s.' % coverage_version)
23
24 10
25 # This is instead of a contextmanager because it causes old pylints to crash :( 11 # This is instead of a contextmanager because it causes old pylints to crash :(
26 class _Cover(object): 12 class _Cover(object):
27 def __init__(self, enabled, maybe_kwargs): 13 def __init__(self, enabled, maybe_kwargs):
28 self.enabled = enabled 14 self.enabled = enabled
29 self.kwargs = maybe_kwargs or {} 15 self.kwargs = maybe_kwargs or {}
30 self.c = None 16 self.c = None
31 17
32 def __enter__(self): 18 def __enter__(self):
33 if self.enabled: 19 if self.enabled:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 print 66 print
81 print 'FATAL: Test coverage is not at 100%.' 67 print 'FATAL: Test coverage is not at 100%.'
82 68
83 return not fail 69 return not fail
84 70
85 def create_subprocess_context(self): 71 def create_subprocess_context(self):
86 # Can't have this method be the contextmanager because otherwise 72 # Can't have this method be the contextmanager because otherwise
87 # self (and self.cov) will get pickled to the subprocess, and we don't want 73 # self (and self.cov) will get pickled to the subprocess, and we don't want
88 # that :( 74 # that :(
89 return _Cover(self.enabled, self.opts) 75 return _Cover(self.enabled, self.opts)
OLDNEW
« no previous file with comments | « scripts/slave/unittests/__init__.py ('k') | scripts/slave/unittests/recipe_configs_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698