From 44f159685332b81894a912d3cbf5a207e4aa9475 Mon Sep 17 00:00:00 2001 From: Adrien Ferrand Date: Fri, 31 Jan 2020 20:35:31 +0100 Subject: [PATCH] Add confirmation for this destructive test --- .../templates/installer-tests.yml | 2 +- .../conftest.py | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.azure-pipelines/templates/installer-tests.yml b/.azure-pipelines/templates/installer-tests.yml index 8c2ba069a..d3590812f 100644 --- a/.azure-pipelines/templates/installer-tests.yml +++ b/.azure-pipelines/templates/installer-tests.yml @@ -48,7 +48,7 @@ jobs: displayName: Prepare Certbot-CI - script: | set PATH=%ProgramFiles(x86)%\Certbot\bin;%PATH% - venv\Scripts\python -m pytest certbot-ci\windows_installer_integration_tests --installer-path $(Build.SourcesDirectory)\bin\certbot-beta-installer-win32.exe + venv\Scripts\python -m pytest certbot-ci\windows_installer_integration_tests --confirm --installer-path $(Build.SourcesDirectory)\bin\certbot-beta-installer-win32.exe displayName: Run windows installer integration tests - script: | set PATH=%ProgramFiles(x86)%\Certbot\bin;%PATH% diff --git a/certbot-ci/windows_installer_integration_tests/conftest.py b/certbot-ci/windows_installer_integration_tests/conftest.py index c77f47070..1146ce256 100644 --- a/certbot-ci/windows_installer_integration_tests/conftest.py +++ b/certbot-ci/windows_installer_integration_tests/conftest.py @@ -9,6 +9,8 @@ See https://docs.pytest.org/en/latest/reference.html#hook-reference from __future__ import print_function import os +import pytest + ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) @@ -22,3 +24,26 @@ def pytest_addoption(parser): 'nsis', 'certbot-beta-installer-win32.exe'), help='set the path of the windows installer to use, default to ' 'CERTBOT_ROOT_PATH\\windows-installer\\build\\nsis\\certbot-beta-installer-win32.exe') + parser.addoption('--confirm', action='store_true', + help='if set, this test will not ask for user confirmation before running') + + +def pytest_configure(config): + """ + Standard pytest hook used to add a configuration logic for each node of a pytest run. + :param config: the current pytest configuration + """ + if not config.option.confirm: + capture_manager = config.pluginmanager.getplugin('capturemanager') + try: + capture_manager.suspendcapture(in_=True) + + print('++ WARNING ++') + print('-------------') + print('This integration test will install Certbot on your machine.') + print('At the end of the test you will need to manually uninstall it.') + print('-------------') + + input('Please press ENTER to continue, or CTRL+C to cancel.') + finally: + capture_manager.resumecapture()