From 4e760bcbfc7ef62002bf63b611417c2580cbea89 Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Thu, 14 May 2020 11:32:01 +0530 Subject: [PATCH] ci: Don't remove .coverage file & set empty suffix. Fixes #14962 * codecov needs `.coverage` file in the pwd to upload coverage results. * cov.data_suffix=False doesn't work anymore. So we explicity set it to "". Filed issue as https://github.com/nedbat/coveragepy/issues/989 --- tools/ci/backend | 2 +- tools/coveragerc | 1 - tools/test-backend | 13 +++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/ci/backend b/tools/ci/backend index 6122cf53b38ce0..3f6278ae2a71b5 100755 --- a/tools/ci/backend +++ b/tools/ci/backend @@ -12,7 +12,7 @@ set -x # docker setup means the auto-detection logic sees the ~36 processes # the Docker host has, not the ~2 processes of resources we're # allocated. -./tools/test-backend --coverage --include-webhooks --parallel=6 +./tools/test-backend --coverage --include-webhooks --no-cov-cleanup --parallel=6 # We run mypy after the backend tests so we get output from the # backend tests, which tend to uncover more serious problems, first. diff --git a/tools/coveragerc b/tools/coveragerc index 24b0536d71b231..9dffa8894b57ab 100644 --- a/tools/coveragerc +++ b/tools/coveragerc @@ -24,7 +24,6 @@ exclude_lines = ^\s*\.\.\. [run] -data_file=var/.coverage omit = */zulip-venv-cache/* */migrations/* diff --git a/tools/test-backend b/tools/test-backend index 9a92d38c21c558..09426b69e88d89 100755 --- a/tools/test-backend +++ b/tools/test-backend @@ -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")