mirror of
https://github.com/certbot/certbot.git
synced 2026-06-04 22:33:00 -04:00
It was pointed out to me that you can no longer run tox.cover.py directly to run coverage tests on a subset of the packages in this repo. This happened after we did both of: 1. Factored out --pyargs from the different test files and put it in pytest.ini. 2. Moved the options we added to pytest.ini to tox.ini meaning that --pyargs is not set unless you run the file through tox. I think the fact that we factored out --pyargs from the files that needed it was a mistake. --pytest is needed by tox.cover.py and install_and_test.py in order to work correctly. I think CLI options like this which are needed for the file to function should be left in the file directly. Doing anything else in my opinion unnecessarily couples these scripts to other files making them more brittle and harder to maintain. With that said, I also think CLI options which are not needed (such as --numprocesses) can be left to be optionally added through PYTEST_ADDOPTS. * Add --pyargs to tox.cover.py. * Add --pyargs to install_and_test.py. * Remove --pyargs from tox.ini.
81 lines
3.1 KiB
Python
Executable file
81 lines
3.1 KiB
Python
Executable file
#!/usr/bin/env python
|
|
import argparse
|
|
import subprocess
|
|
import os
|
|
import sys
|
|
|
|
DEFAULT_PACKAGES = [
|
|
'certbot', 'acme', 'certbot_apache', 'certbot_dns_cloudflare', 'certbot_dns_cloudxns',
|
|
'certbot_dns_digitalocean', 'certbot_dns_dnsimple', 'certbot_dns_dnsmadeeasy',
|
|
'certbot_dns_gehirn', 'certbot_dns_google', 'certbot_dns_linode', 'certbot_dns_luadns',
|
|
'certbot_dns_nsone', 'certbot_dns_ovh', 'certbot_dns_rfc2136', 'certbot_dns_route53',
|
|
'certbot_dns_sakuracloud', 'certbot_nginx', 'certbot_postfix', 'letshelp_certbot']
|
|
|
|
COVER_THRESHOLDS = {
|
|
'certbot': {'linux': 98, 'windows': 94},
|
|
'acme': {'linux': 100, 'windows': 99},
|
|
'certbot_apache': {'linux': 100, 'windows': 100},
|
|
'certbot_dns_cloudflare': {'linux': 98, 'windows': 98},
|
|
'certbot_dns_cloudxns': {'linux': 99, 'windows': 99},
|
|
'certbot_dns_digitalocean': {'linux': 98, 'windows': 98},
|
|
'certbot_dns_dnsimple': {'linux': 98, 'windows': 98},
|
|
'certbot_dns_dnsmadeeasy': {'linux': 99, 'windows': 99},
|
|
'certbot_dns_gehirn': {'linux': 97, 'windows': 97},
|
|
'certbot_dns_google': {'linux': 99, 'windows': 99},
|
|
'certbot_dns_linode': {'linux': 98, 'windows': 98},
|
|
'certbot_dns_luadns': {'linux': 98, 'windows': 98},
|
|
'certbot_dns_nsone': {'linux': 99, 'windows': 99},
|
|
'certbot_dns_ovh': {'linux': 97, 'windows': 97},
|
|
'certbot_dns_rfc2136': {'linux': 99, 'windows': 99},
|
|
'certbot_dns_route53': {'linux': 92, 'windows': 92},
|
|
'certbot_dns_sakuracloud': {'linux': 97, 'windows': 97},
|
|
'certbot_nginx': {'linux': 97, 'windows': 97},
|
|
'certbot_postfix': {'linux': 100, 'windows': 100},
|
|
'letshelp_certbot': {'linux': 100, 'windows': 100}
|
|
}
|
|
|
|
SKIP_PROJECTS_ON_WINDOWS = [
|
|
'certbot-apache', 'certbot-nginx', 'certbot-postfix', 'letshelp-certbot']
|
|
|
|
def cover(package):
|
|
threshold = COVER_THRESHOLDS.get(package)['windows' if os.name == 'nt' else 'linux']
|
|
|
|
pkg_dir = package.replace('_', '-')
|
|
|
|
if os.name == 'nt' and pkg_dir in SKIP_PROJECTS_ON_WINDOWS:
|
|
print((
|
|
'Info: currently {0} is not supported on Windows and will not be tested/covered.'
|
|
.format(pkg_dir)))
|
|
return
|
|
|
|
subprocess.check_call([sys.executable, '-m', 'pytest', '--pyargs',
|
|
'--cov', pkg_dir, '--cov-append', '--cov-report=', package])
|
|
subprocess.check_call([
|
|
sys.executable, '-m', 'coverage', 'report', '--fail-under', str(threshold), '--include',
|
|
'{0}/*'.format(pkg_dir), '--show-missing'])
|
|
|
|
def main():
|
|
description = """
|
|
This script is used by tox.ini (and thus by Travis CI and AppVeyor) in order
|
|
to generate separate stats for each package. It should be removed once those
|
|
packages are moved to a separate repo.
|
|
|
|
Option -e makes sure we fail fast and don't submit to codecov."""
|
|
parser = argparse.ArgumentParser(description=description)
|
|
parser.add_argument('--packages', nargs='+')
|
|
|
|
args = parser.parse_args()
|
|
|
|
packages = args.packages or DEFAULT_PACKAGES
|
|
|
|
# --cov-append is on, make sure stats are correct
|
|
try:
|
|
os.remove('.coverage')
|
|
except OSError:
|
|
pass
|
|
|
|
for package in packages:
|
|
cover(package)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|