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

Side by Side Diff: testing_support/coverage_utils.py

Issue 26109002: Add git-number script to calculate generation numbers for commits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 7 years, 1 month 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
OLDNEW
(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
9
10 def covered_main(includes):
11 """Equivalent of unittest.main(), except that it gathers coverage data, and
12 asserts if the test is not at 100% coverage.
13
14 Args:
15 includes (list(str) or str) - List of paths to include in coverage report.
16 May also be a single path instead of a list.
17 """
18 try:
19 import coverage
20 except ImportError:
21 sys.path.insert(0,
22 os.path.abspath(os.path.join(
23 os.path.dirname(os.path.dirname(__file__)), 'third_party')))
M-A Ruel 2013/11/14 17:27:24 I still prefer this to be a global variable.
iannucci 2013/11/15 02:12:58 Aw, nuts, I thought I did that.
24 import coverage
25 COVERAGE = coverage.coverage(include=includes)
26 COVERAGE.start()
27
28 retcode = 0
29 try:
30 unittest.main()
31 except SystemExit as e:
32 retcode = e.code or retcode
33
34 COVERAGE.stop()
35 if COVERAGE.report() != 100.0:
36 print "FATAL: not at 100% coverage."
37 retcode = 2
38
39 return retcode
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698