mirror of
https://github.com/certbot/certbot.git
synced 2026-06-21 06:29:08 -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.
57 lines
1.8 KiB
Python
Executable file
57 lines
1.8 KiB
Python
Executable file
#!/usr/bin/env python
|
|
# pip installs the requested packages in editable mode and runs unit tests on
|
|
# them. Each package is installed and tested in the order they are provided
|
|
# before the script moves on to the next package. If CERTBOT_NO_PIN is set not
|
|
# set to 1, packages are installed using pinned versions of all of our
|
|
# dependencies. See pip_install.py for more information on the versions pinned
|
|
# to.
|
|
from __future__ import print_function
|
|
|
|
import os
|
|
import sys
|
|
import tempfile
|
|
import shutil
|
|
import subprocess
|
|
import re
|
|
|
|
SKIP_PROJECTS_ON_WINDOWS = [
|
|
'certbot-apache', 'certbot-nginx', 'certbot-postfix', 'letshelp-certbot']
|
|
|
|
|
|
def call_with_print(command, cwd=None):
|
|
print(command)
|
|
subprocess.check_call(command, shell=True, cwd=cwd or os.getcwd())
|
|
|
|
|
|
def main(args):
|
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
|
command = [sys.executable, os.path.join(script_dir, 'pip_install_editable.py')]
|
|
|
|
new_args = []
|
|
for arg in args:
|
|
if os.name == 'nt' and arg in SKIP_PROJECTS_ON_WINDOWS:
|
|
print((
|
|
'Info: currently {0} is not supported on Windows and will not be tested.'
|
|
.format(arg)))
|
|
else:
|
|
new_args.append(arg)
|
|
|
|
for requirement in new_args:
|
|
current_command = command[:]
|
|
current_command.append(requirement)
|
|
call_with_print(' '.join(current_command))
|
|
pkg = re.sub(r'\[\w+\]', '', requirement)
|
|
|
|
if pkg == '.':
|
|
pkg = 'certbot'
|
|
|
|
temp_cwd = tempfile.mkdtemp()
|
|
shutil.copy2("pytest.ini", temp_cwd)
|
|
try:
|
|
call_with_print(' '.join([
|
|
sys.executable, '-m', 'pytest', '--pyargs', pkg.replace('-', '_')]), cwd=temp_cwd)
|
|
finally:
|
|
shutil.rmtree(temp_cwd)
|
|
|
|
if __name__ == '__main__':
|
|
main(sys.argv[1:])
|