From d3ae77b37dff01eb866fd77e1a9bc2dc283ba6a6 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Mon, 25 Mar 2019 15:07:39 +0000 Subject: [PATCH] Add separate crypto sessions --- .pre-commit-config.yaml | 16 +++--- noxfile.py | 109 ++++++++++++++++++++++++++++++++++------ 2 files changed, 101 insertions(+), 24 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 32c58ba8b2..cd9f130192 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: - id: pip-tools-compile alias: compile-linux-py3-zmq-requirements name: Linux Py3 ZeroMQ Requirements - files: ^requirements/static/(.*)\.in$ + files: ^requirements/((base|zeromq|pytest)\.txt|static/(.*)\.in)$ exclude: ^requirements/static/windows\.in$ args: - --out-prefix=zeromq @@ -16,7 +16,7 @@ repos: - id: pip-tools-compile alias: compile-linux-py2-zmq-requirements name: Linux Py2 ZeroMQ Requirements - files: ^requirements/static/(.*)\.in$ + files: ^requirements/((base|zeromq|pytest)\.txt|static/(.*)\.in)$ exclude: ^requirements/static/windows\.in$ args: - --out-prefix=zeromq @@ -26,7 +26,7 @@ repos: - id: pip-tools-compile alias: compile-linux-py3-raet-requirements name: Linux Py3 RAET Requirements - files: ^requirements/static/(.*)\.in$ + files: ^requirements/((base|raet|pytest)\.txt|static/(.*)\.in)$ exclude: ^requirements/static/windows\.in$ args: - --out-prefix=raet @@ -36,7 +36,7 @@ repos: - id: pip-tools-compile alias: compile-linux-py2-raet-requirements name: Linux Py2 RAET Requirements - files: ^requirements/static/(.*)\.in$ + files: ^requirements/((base|raet|pytest)\.txt|static/(.*)\.in)$ exclude: ^requirements/static/windows\.in$ args: - --out-prefix=raet @@ -46,7 +46,7 @@ repos: - id: pip-tools-compile alias: compile-windows-py3-zmq-requirements name: Windows Py3 ZeroMQ Requirements - files: ^requirements/static/windows\.in$ + files: ^requirements/((base|zeromq|pytest)\.txt|static/windows\.in)$ args: - --platform=windows - --out-prefix=zeromq @@ -56,7 +56,7 @@ repos: - id: pip-tools-compile alias: compile-windows-py2-zmq-requirements name: Windows Py2 ZeroMQ Requirements - files: ^requirements/static/windows\.in$ + files: ^requirements/((base|zeromq|pytest)\.txt|static/windows\.in)$ args: - --platform=windows - --out-prefix=zeromq @@ -66,7 +66,7 @@ repos: - id: pip-tools-compile alias: compile-windows-py3-raet-requirements name: Windows Py3 RAET Requirements - files: ^requirements/static/windows\.in$ + files: ^requirements/((base|raet|pytest)\.txt|static/windows\.in)$ args: - --out-prefix=raet - --platform=windows @@ -76,7 +76,7 @@ repos: - id: pip-tools-compile alias: compile-windows-py2-raet-requirements name: Windows Py2 RAET Requirements - files: ^requirements/static/windows\.in$ + files: ^requirements/((base|raet|pytest)\.txt|static/windows\.in)$ args: - --out-prefix=raet - --platform=windows diff --git a/noxfile.py b/noxfile.py index ab8476677e..8472719a5c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -164,22 +164,9 @@ def _run_with_coverage(session, *test_cmd): session.run('coverage', 'xml', '-o', os.path.join(REPO_ROOT, 'artifacts', 'coverage', 'coverage.xml')) -@nox.session(python=_PYTHON_VERSIONS) -@nox.parametrize('coverage', [False, True]) -@nox.parametrize('transport', ['zeromq', 'raet']) -def runtests(session, coverage, transport): - # Install requirements - _install_requirements(session, transport, 'unittest-xml-reporting==2.2.1') +def _runtests(session, coverage, transport, cmd_args): # Create required artifacts directories _create_ci_directories() - - cmd_args = [ - '--tests-logfile={}'.format( - os.path.join(REPO_ROOT, 'artifacts', 'logs', 'runtests.log') - ), - '--transport={}'.format(transport) - ] + session.posargs - try: if coverage is True: _run_with_coverage(session, 'coverage', 'run', '-m', 'tests.runtests', *cmd_args) @@ -222,14 +209,61 @@ def runtests(session, coverage, transport): session.run('python', os.path.join('tests', 'runtests.py'), *cmd_args) +@nox.session(python=_PYTHON_VERSIONS) +@nox.parametrize('coverage', [False, True]) +@nox.parametrize('transport', ['zeromq', 'raet']) +def runtests(session, coverage, transport): + # Install requirements + _install_requirements(session, transport, 'unittest-xml-reporting==2.2.1') + + cmd_args = [ + '--tests-logfile={}'.format( + os.path.join(REPO_ROOT, 'artifacts', 'logs', 'runtests.log') + ), + '--transport={}'.format(transport) + ] + session.posargs + _runtests(session, coverage, transport, cmd_args) + + +def _runtests_crypto(session, coverage, transport, crypto): + # Install requirements + _install_requirements(session, transport, 'unittest-xml-reporting==2.2.1') + + if crypto == 'm2crypto': + session.run('pip', 'uninstall', '-y', 'pycrypto', 'pycryptodome', 'pycryptodomex', silent=True) + else: + session.run('pip', 'uninstall', '-y', 'm2crypto', silent=True) + session.install(crypto) + + cmd_args = [ + '--tests-logfile={}'.format( + os.path.join(REPO_ROOT, 'artifacts', 'logs', 'runtests.log') + ), + '--transport={}'.format(transport) + ] + session.posargs + _runtests(session, coverage, transport, cmd_args) + + +@nox.session(python=_PYTHON_VERSIONS, name='runtests-m2crypto') +@nox.parametrize('coverage', [False, True]) +@nox.parametrize('transport', ['zeromq', 'raet']) +def runtests_m2crypto(session, coverage, transport): + _runtests_crypto(session, coverage, transport, 'm2crypto') + + +@nox.session(python=_PYTHON_VERSIONS, name='runtests-pycryptodomex') +@nox.parametrize('coverage', [False, True]) +@nox.parametrize('transport', ['zeromq', 'raet']) +def runtests_pycryptodomex(session, coverage, transport): + _runtests_crypto(session, coverage, transport, 'pycryptodomex') + + @nox.session(python=_PYTHON_VERSIONS) @nox.parametrize('coverage', [False, True]) @nox.parametrize('transport', ['zeromq', 'raet']) def pytest(session, coverage, transport): # Install requirements _install_requirements(session, transport) - # Create required artifacts directories - _create_ci_directories() cmd_args = [ '--rootdir', REPO_ROOT, @@ -241,6 +275,49 @@ def pytest(session, coverage, transport): '-s', '--transport={}'.format(transport) ] + session.posargs + _pytest(session, coverage, transport, cmd_args) + + +def _pytest_crypto(session, coverage, transport, crypto): + # Install requirements + _install_requirements(session, transport) + + if crypto == 'm2crypto': + session.run('pip', 'uninstall', '-y', 'pycrypto', 'pycryptodome', 'pycryptodomex', silent=True) + else: + session.run('pip', 'uninstall', '-y', 'm2crypto', silent=True) + session.install(crypto) + + cmd_args = [ + '--rootdir', REPO_ROOT, + '--log-file={}'.format( + os.path.join(REPO_ROOT, 'artifacts', 'logs', 'runtests.log') + ), + '--no-print-logs', + '-ra', + '-s', + '--transport={}'.format(transport) + ] + session.posargs + _pytest(session, coverage, transport, cmd_args) + + +@nox.session(python=_PYTHON_VERSIONS, name='pytest-m2crypto') +@nox.parametrize('coverage', [False, True]) +@nox.parametrize('transport', ['zeromq', 'raet']) +def pytest_m2crypto(session, coverage, transport): + _pytest_crypto(session, coverage, transport, 'm2crypto') + + +@nox.session(python=_PYTHON_VERSIONS, name='pytest-pycryptodomex') +@nox.parametrize('coverage', [False, True]) +@nox.parametrize('transport', ['zeromq', 'raet']) +def pytest_pycryptodomex(session, coverage, transport): + _pytest_crypto(session, coverage, transport, 'pycryptodomex') + + +def _pytest(session, coverage, transport, cmd_args): + # Create required artifacts directories + _create_ci_directories() try: if coverage is True: