Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/certbot/certbot.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tools/install_and_test.py')
-rwxr-xr-xtools/install_and_test.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/install_and_test.py b/tools/install_and_test.py
new file mode 100755
index 000000000..149ffc776
--- /dev/null
+++ b/tools/install_and_test.py
@@ -0,0 +1,62 @@
+#!/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)
+ return subprocess.call(command, shell=True, cwd=cwd or os.getcwd())
+
+def main(args):
+ if os.environ.get('CERTBOT_NO_PIN') == '1':
+ command = [sys.executable, '-m', 'pip', '-q', '-e']
+ else:
+ 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)
+
+ exit_code = 0
+
+ for requirement in new_args:
+ current_command = command[:]
+ current_command.append(requirement)
+ exit_code = call_with_print(' '.join(current_command)) or exit_code
+ pkg = re.sub(r'\[\w+\]', '', requirement)
+
+ if pkg == '.':
+ pkg = 'certbot'
+
+ temp_cwd = tempfile.mkdtemp()
+ try:
+ exit_code = call_with_print(' '.join([
+ sys.executable, '-m', 'pytest', '--numprocesses', 'auto',
+ '--quiet', '--pyargs', pkg.replace('-', '_')]), cwd=temp_cwd) or exit_code
+ finally:
+ shutil.rmtree(temp_cwd)
+
+ return exit_code
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))