Phil Dawson pushed to branch phil/external-plugin-testing at BuildStream / buildstream
Commits:
-
82e36c26
by Phil Dawson at 2019-02-18T17:48:44Z
3 changed files:
Changes:
| ... | ... | @@ -12,7 +12,7 @@ test=pytest |
| 12 | 12 |
|
| 13 | 13 |
[tool:pytest]
|
| 14 | 14 |
addopts = --verbose --basetemp ./tmp --cov=buildstream --cov-config .coveragerc --durations=20
|
| 15 |
-norecursedirs = tests/integration/project integration-cache tmp __pycache__ .eggs
|
|
| 15 |
+norecursedirs = tests/integration/project integration-cache tmp __pycache__ .eggs tests/external_plugins/
|
|
| 16 | 16 |
python_files = tests/*/*.py
|
| 17 | 17 |
env =
|
| 18 | 18 |
D:BST_TEST_SUITE=True
|
| 1 |
+import pytest
|
|
| 2 |
+import subprocess
|
|
| 3 |
+import os
|
|
| 4 |
+import sys
|
|
| 5 |
+import shutil
|
|
| 6 |
+import time
|
|
| 7 |
+ |
|
| 8 |
+ALL_EXTERNAL_PLUGINS = [
|
|
| 9 |
+ ExternalPluginRepo(
|
|
| 10 |
+ name='bst-external',
|
|
| 11 |
+ url='https://gitlab.com/BuildStream/bst-external.git',
|
|
| 12 |
+ ref='master'
|
|
| 13 |
+ ),
|
|
| 14 |
+]
|
|
| 15 |
+BST_SOURCE_PATH = ''
|
|
| 16 |
+PYTEST_ARGS = ['--cov-append', '--cov=buildstream']
|
|
| 17 |
+TEST_COMMAND = ['pytest', *PYTEST_ARGS]
|
|
| 18 |
+ |
|
| 19 |
+ |
|
| 20 |
+class ExternalPluginRepo():
|
|
| 21 |
+ def __init__(self, name=None, url=None, ref=None):
|
|
| 22 |
+ self.name = name
|
|
| 23 |
+ self.url = url
|
|
| 24 |
+ self.ref = ref
|
|
| 25 |
+ self._clone_location = None
|
|
| 26 |
+ |
|
| 27 |
+ def clone(self, location):
|
|
| 28 |
+ self._clone_location = os.path.join(location, self.name)
|
|
| 29 |
+ subprocess.run(['git', 'clone',
|
|
| 30 |
+ '--single-branch',
|
|
| 31 |
+ '--branch', 'master',
|
|
| 32 |
+ '--depth', '1',
|
|
| 33 |
+ self.url,
|
|
| 34 |
+ self._clone_location,
|
|
| 35 |
+ ])
|
|
| 36 |
+ return self._clone_location
|
|
| 37 |
+ |
|
| 38 |
+ def install(self):
|
|
| 39 |
+ subprocess.run(['pip3', 'install', self._clone_location])
|
|
| 40 |
+ |
|
| 41 |
+ def test(self, pytest_args):
|
|
| 42 |
+ return pytest.main(PYTEST_ARGS
|
|
| 43 |
+ + pytest_args
|
|
| 44 |
+ + [os.path.join(self._clone_location, 'tests')]
|
|
| 45 |
+ )
|
|
| 46 |
+ |
|
| 47 |
+ |
|
| 48 |
+def run_repo_tests(repo, tmpdir, pytest_args):
|
|
| 49 |
+ print("Cloning repo {} to {}...".format(repo.name, tmpdir))
|
|
| 50 |
+ repo.clone(tmpdir)
|
|
| 51 |
+ |
|
| 52 |
+ print("Installing {}...".format(repo.name))
|
|
| 53 |
+ repo.install()
|
|
| 54 |
+ |
|
| 55 |
+ print("Testing {}...".format(repo.name))
|
|
| 56 |
+ return repo.test(pytest_args)
|
|
| 57 |
+ |
|
| 58 |
+ |
|
| 59 |
+if __name__ == "__main__":
|
|
| 60 |
+ from sys import argv
|
|
| 61 |
+ |
|
| 62 |
+ _, tmpdir, *pytest_args = argv
|
|
| 63 |
+ |
|
| 64 |
+ bst_external = ExternalPluginRepo(
|
|
| 65 |
+ name='bst-external',
|
|
| 66 |
+ url='https://gitlab.com/BuildStream/bst-external.git',
|
|
| 67 |
+ ref='master'
|
|
| 68 |
+ )
|
|
| 69 |
+ |
|
| 70 |
+ exit_code = 0
|
|
| 71 |
+ for plugin in ALL_EXTERNAL_PLUGINS:
|
|
| 72 |
+ exit_code = run_repo_tests(bst_external, tmpdir, pytest_args)
|
|
| 73 |
+ if exit_code != 0:
|
|
| 74 |
+ sys.exit(exit_code)
|
| ... | ... | @@ -13,6 +13,8 @@ skip_missing_interpreters = true |
| 13 | 13 |
[testenv]
|
| 14 | 14 |
commands =
|
| 15 | 15 |
pytest --basetemp {envtmpdir} {posargs}
|
| 16 |
+ pip3 install -e {toxinidir}
|
|
| 17 |
+ {envpython} {toxinidir}/tests/external_plugins.py {envtmpdir} {posargs}
|
|
| 16 | 18 |
mkdir -p .coverage-reports
|
| 17 | 19 |
mv {envtmpdir}/.coverage {toxinidir}/.coverage-reports/.coverage.{env:COVERAGE_PREFIX:}{envname}
|
| 18 | 20 |
deps =
|
| ... | ... | @@ -59,6 +61,7 @@ deps = |
| 59 | 61 |
-rrequirements/dev-requirements.txt
|
| 60 | 62 |
-rrequirements/plugin-requirements.txt
|
| 61 | 63 |
|
| 64 |
+ |
|
| 62 | 65 |
#
|
| 63 | 66 |
# Building documentation
|
| 64 | 67 |
#
|
