ci: Don't remove .coverage file & set empty suffix.

Fixes #14962
* codecov needs `.coverage` file in the pwd to upload coverage
results.
* concurrency='multiprocessing' forces `.coverage` file to have a
data_suffix, we explicity set it to "" for the file to have no suffix.
Filed issue as https://github.com/nedbat/coveragepy/issues/989
This commit is contained in:
Aman Agrawal
2020-05-14 11:32:01 +05:30
committed by Tim Abbott
parent 12fd515831
commit c9bff71410
3 changed files with 23 additions and 9 deletions

View File

@@ -216,6 +216,10 @@ def main() -> None:
parser.add_argument('--verbose-coverage', dest='verbose_coverage',
action="store_true",
default=False, help='Enable verbose print of coverage report.')
parser.add_argument('--no-cov-cleanup', dest='no_cov_cleanup',
action='store_true',
default=False,
help="Do not clean generated coverage files.")
parser.add_argument('--parallel', dest='processes',
type=int,
@@ -354,10 +358,12 @@ def main() -> None:
assert_provisioning_status_ok(options.force)
if options.coverage:
import atexit
import coverage
cov = coverage.Coverage(config_file="tools/coveragerc", concurrency='multiprocessing')
atexit.register(lambda: cov.erase()) # Ensure the data file gets cleaned up at the end.
cov = coverage.Coverage(data_suffix="", config_file="tools/coveragerc", concurrency='multiprocessing')
# Do not clean .coverage file in CircleCi job so that coverage data can be uploaded.
if not options.no_cov_cleanup:
import atexit
atexit.register(lambda: cov.erase()) # Ensure the data file gets cleaned up at the end.
cov.start()
if options.profile:
import cProfile
@@ -407,7 +413,6 @@ def main() -> None:
cov.stop()
cov.save()
cov.combine()
cov.data_suffix = False # Disable suffix so that filename is .coverage
cov.save()
if options.verbose_coverage:
print("Printing coverage data")