| OLD | NEW |
| 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 import os | 6 import os |
| 7 import socket | 7 import socket |
| 8 import threading | 8 import threading |
| 9 | 9 |
| 10 import coverage | 10 import coverage |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 def report(self, verbose, threshold, omit=None): | 77 def report(self, verbose, threshold, omit=None): |
| 78 fail = False | 78 fail = False |
| 79 | 79 |
| 80 if self.enabled: | 80 if self.enabled: |
| 81 if self.html_report: | 81 if self.html_report: |
| 82 self.cov.html_report(directory=self.html_report, omit=omit) | 82 self.cov.html_report(directory=self.html_report, omit=omit) |
| 83 | 83 |
| 84 outf = StringIO() | 84 outf = StringIO() |
| 85 | 85 |
| 86 try: | 86 try: |
| 87 coverage_percent = self.cov.report(file=outf, omit=omit) | 87 coverage_percent = self.cov.report( |
| 88 file=outf, omit=omit, show_missing=True) |
| 88 except coverage.CoverageException as ce: | 89 except coverage.CoverageException as ce: |
| 89 if ce.message != 'No data to report.': | 90 if ce.message != 'No data to report.': |
| 90 raise | 91 raise |
| 91 # If we have no data to report, this means that coverage has found no | 92 # If we have no data to report, this means that coverage has found no |
| 92 # tests in the module. Earlier version of coverage used to return 100 in | 93 # tests in the module. Earlier version of coverage used to return 100 in |
| 93 # this case, so we simulate it to keep backward compatibility. | 94 # this case, so we simulate it to keep backward compatibility. |
| 94 coverage_percent = 100.0 | 95 coverage_percent = 100.0 |
| 95 if verbose: | 96 if verbose: |
| 96 print 'No data to report, setting coverage to 100%' | 97 print 'No data to report, setting coverage to 100%' |
| 97 | 98 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 110 print ('FATAL: Test coverage %.f%% is not the required %.f%% threshold' | 111 print ('FATAL: Test coverage %.f%% is not the required %.f%% threshold' |
| 111 % (int(coverage_percent), int(threshold))) | 112 % (int(coverage_percent), int(threshold))) |
| 112 | 113 |
| 113 return not fail | 114 return not fail |
| 114 | 115 |
| 115 def create_subprocess_context(self): | 116 def create_subprocess_context(self): |
| 116 # Can't have this method be the contextmanager because otherwise | 117 # Can't have this method be the contextmanager because otherwise |
| 117 # self (and self.cov) will get pickled to the subprocess, and we don't want | 118 # self (and self.cov) will get pickled to the subprocess, and we don't want |
| 118 # that :( | 119 # that :( |
| 119 return _Cover(self.enabled, self.opts) | 120 return _Cover(self.enabled, self.opts) |
| OLD | NEW |