OLD | NEW |
---|---|
(Empty) | |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 import os | |
6 import sys | |
7 import unittest | |
8 | |
M-A Ruel
2013/11/08 19:32:23
2 lines
iannucci
2013/11/11 22:59:24
Done.
| |
9 def covered_main(includes): | |
10 """Equivalent of unittest.main(), except that it gathers coverage data, and | |
11 asserts if the test is not at 100% coverage. | |
12 | |
13 Args: | |
14 includes (list(str) or str) - List of paths to include in coverage report. | |
15 May also be a single path instead of a list. | |
16 """ | |
17 try: | |
18 import coverage | |
19 except ImportError: | |
20 sys.path.insert(0, | |
21 os.path.abspath(os.path.join( | |
22 os.path.dirname(os.path.dirname(__file__)), 'third_party'))) | |
23 import coverage | |
24 COVERAGE = coverage.coverage(include=includes) | |
25 COVERAGE.start() | |
26 | |
27 retcode = 0 | |
28 try: | |
29 unittest.main() | |
30 except SystemExit as e: | |
31 retcode = e.code or retcode | |
32 | |
33 COVERAGE.stop() | |
34 if COVERAGE.report() != 100.0: | |
35 print "FATAL: not at 100% coverage." | |
36 retcode = 2 | |
37 | |
38 return retcode | |
OLD | NEW |