summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-09-04 16:49:12 -0400
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-09-04 16:49:12 -0400
commit193bc3c195e9d0843d38f4a7e4eecac5b8daa1a2 (patch)
tree200db2d52b66343249b82c2f1092b1937838eedc
parent60297032d9a95d88b5812dbd02b1e44f95db913e (diff)
downloadbuildstream-193bc3c195e9d0843d38f4a7e4eecac5b8daa1a2.tar.gz
Restructuring tests using the Repo and Cli
Make all the test batteries which run on all the source backends we have repo scaffoldings for discover the list of Repo implementations automatically.
-rw-r--r--tests/frontend/buildcheckout.py5
-rw-r--r--tests/frontend/fetch.py6
-rw-r--r--tests/frontend/track.py6
-rw-r--r--tests/frontend/workspace.py7
-rw-r--r--tests/testutils/__init__.py2
-rw-r--r--tests/testutils/repo/__init__.py14
6 files changed, 18 insertions, 22 deletions
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index e05b947b7..4a70c7c82 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -1,7 +1,6 @@
import os
import pytest
-from tests.testutils.runcli import cli
-from tests.testutils.repo import create_repo
+from tests.testutils import cli, create_repo, ALL_REPO_KINDS
from buildstream import _yaml
@@ -37,7 +36,7 @@ def test_build_checkout(datafiles, cli):
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("kind", [('git'), ('bzr'), ('ostree'), ('tar')])
+@pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS])
def test_fetch_build_checkout(cli, tmpdir, datafiles, kind):
checkout = os.path.join(cli.directory, 'checkout')
project = os.path.join(datafiles.dirname, datafiles.basename)
diff --git a/tests/frontend/fetch.py b/tests/frontend/fetch.py
index 23e6b3a35..e8c22c6f7 100644
--- a/tests/frontend/fetch.py
+++ b/tests/frontend/fetch.py
@@ -1,11 +1,9 @@
import os
import pytest
-from tests.testutils.runcli import cli
-from tests.testutils.repo import create_repo
+from tests.testutils import cli, create_repo, ALL_REPO_KINDS
from buildstream import _yaml
-
# Project directory
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
@@ -14,7 +12,7 @@ DATA_DIR = os.path.join(
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("kind", [('git'), ('bzr'), ('ostree'), ('tar')])
+@pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS])
def test_fetch(cli, tmpdir, datafiles, kind):
project = os.path.join(datafiles.dirname, datafiles.basename)
bin_files_path = os.path.join(project, 'files', 'bin-files')
diff --git a/tests/frontend/track.py b/tests/frontend/track.py
index e4364e687..af899bd04 100644
--- a/tests/frontend/track.py
+++ b/tests/frontend/track.py
@@ -1,11 +1,9 @@
import os
import pytest
-from tests.testutils.runcli import cli
-from tests.testutils.repo import create_repo
+from tests.testutils import cli, create_repo, ALL_REPO_KINDS
from buildstream import _yaml
-
# Project directory
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
@@ -14,7 +12,7 @@ DATA_DIR = os.path.join(
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("kind", [('git'), ('bzr'), ('ostree'), ('tar')])
+@pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS])
def test_track(cli, tmpdir, datafiles, kind):
project = os.path.join(datafiles.dirname, datafiles.basename)
dev_files_path = os.path.join(project, 'files', 'dev-files')
diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py
index 7010f7d20..db0414a91 100644
--- a/tests/frontend/workspace.py
+++ b/tests/frontend/workspace.py
@@ -1,12 +1,11 @@
import os
import pytest
import shutil
-from tests.testutils.runcli import cli
-from tests.testutils.repo import create_repo
+from tests.testutils import cli, create_repo, ALL_REPO_KINDS
from buildstream import _yaml
-repo_kinds = [('git'), ('bzr'), ('ostree'), ('tar')]
+repo_kinds = [(kind) for kind in ALL_REPO_KINDS]
# Project directory
DATA_DIR = os.path.join(
@@ -161,7 +160,7 @@ def test_list(cli, tmpdir, datafiles, kind):
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("kind", [('git'), ('bzr'), ('ostree'), ('tar')])
+@pytest.mark.parametrize("kind", repo_kinds)
def test_build(cli, tmpdir, datafiles, kind):
element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False)
checkout = os.path.join(str(tmpdir), 'checkout')
diff --git a/tests/testutils/__init__.py b/tests/testutils/__init__.py
index e69de29bb..03072fb35 100644
--- a/tests/testutils/__init__.py
+++ b/tests/testutils/__init__.py
@@ -0,0 +1,2 @@
+from .runcli import cli
+from .repo import create_repo, ALL_REPO_KINDS
diff --git a/tests/testutils/repo/__init__.py b/tests/testutils/repo/__init__.py
index 4651c8519..c3b54a739 100644
--- a/tests/testutils/repo/__init__.py
+++ b/tests/testutils/repo/__init__.py
@@ -1,15 +1,15 @@
+from collections import OrderedDict
import pytest
from .git import Git
from .bzr import Bzr
from .ostree import OSTree
from .tar import Tar
-available_repos = {
- 'git': Git,
- 'bzr': Bzr,
- 'ostree': OSTree,
- 'tar': Tar
-}
+ALL_REPO_KINDS = OrderedDict()
+ALL_REPO_KINDS['git'] = Git
+ALL_REPO_KINDS['bzr'] = Bzr
+ALL_REPO_KINDS['ostree'] = OSTree
+ALL_REPO_KINDS['tar'] = Tar
# create_repo()
@@ -22,7 +22,7 @@ available_repos = {
#
def create_repo(kind, directory):
try:
- constructor = available_repos[kind]
+ constructor = ALL_REPO_KINDS[kind]
except KeyError as e:
raise AssertionError("Unsupported repo kind {}".format(kind)) from e