-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from LeastAuthority/11.correct-coverage-collected
Collect the correct coverage information
- Loading branch information
Showing
6 changed files
with
105 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
# -*- mode: conf -*- | ||
|
||
[run] | ||
# only record trace data for allmydata.* | ||
# only record trace data for this package | ||
source = | ||
allmydata | ||
# and don't trace the test files themselves, or generated files | ||
magic_folder | ||
# and don't trace the test files themselves | ||
omit = | ||
*/allmydata/test/* | ||
*/allmydata/_version.py | ||
*/magic_folder/test/* | ||
parallel = True | ||
branch = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
|
||
from twisted.application.service import ( | ||
Service, | ||
) | ||
|
||
class _CoverageService(Service): | ||
def startService(self): | ||
import coverage | ||
|
||
Service.startService(self) | ||
|
||
# this doesn't change the shell's notion of the environment, but it make | ||
# the test in process_startup() succeed, which is the goal here. | ||
os.environ["COVERAGE_PROCESS_START"] = ".coveragerc" | ||
|
||
# maybe-start the global coverage, unless it already got started | ||
self.cov = coverage.process_startup() | ||
if self.cov is None: | ||
self.cov = coverage.process_startup.coverage | ||
|
||
def stopService(self): | ||
""" | ||
Make sure that coverage has stopped; internally, it depends on ataxit | ||
handlers running which doesn't always happen (Twisted's shutdown hook | ||
also won't run if os._exit() is called, but it runs more-often than | ||
atexit handlers). | ||
""" | ||
self.cov.stop() | ||
self.cov.save() | ||
|
||
|
||
def coverage_service(): | ||
""" | ||
Return a service which will arrange for coverage to be collected (or fail | ||
if the ``coverage`` package is not installed). | ||
""" | ||
return _CoverageService() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters