diff options
author | Valentin David <valentin.david@codethink.co.uk> | 2018-06-11 15:33:11 +0200 |
---|---|---|
committer | Tiago Gomes <tiago.gomes@codethink.co.uk> | 2018-08-03 12:54:30 +0100 |
commit | 70e5d36d4af1ffa1ab8ba7af5abac69b0975de6b (patch) | |
tree | 49d6ee92d99956945b62201335bbaec89ea028c8 | |
parent | 168e1673360ad334a27025e2f1a8413b7ee34b6a (diff) | |
download | buildstream-70e5d36d4af1ffa1ab8ba7af5abac69b0975de6b.tar.gz |
Move tests.frontend.generate_junction to test.testutils
-rw-r--r-- | tests/frontend/__init__.py | 34 | ||||
-rw-r--r-- | tests/frontend/buildcheckout.py | 4 | ||||
-rw-r--r-- | tests/frontend/fetch.py | 4 | ||||
-rw-r--r-- | tests/frontend/pull.py | 3 | ||||
-rw-r--r-- | tests/frontend/push.py | 3 | ||||
-rw-r--r-- | tests/frontend/show.py | 4 | ||||
-rw-r--r-- | tests/frontend/track.py | 4 | ||||
-rw-r--r-- | tests/frontend/track_cross_junction.py | 4 | ||||
-rw-r--r-- | tests/testutils/__init__.py | 1 | ||||
-rw-r--r-- | tests/testutils/junction.py | 36 |
10 files changed, 49 insertions, 48 deletions
diff --git a/tests/frontend/__init__.py b/tests/frontend/__init__.py index 2eadf1519..8cf7625a9 100644 --- a/tests/frontend/__init__.py +++ b/tests/frontend/__init__.py @@ -1,5 +1,4 @@ import os -from tests.testutils import create_repo from buildstream import _yaml @@ -9,36 +8,3 @@ def configure_project(path, config): config['name'] = 'test' config['element-path'] = 'elements' _yaml.dump(config, os.path.join(path, 'project.conf')) - - -# generate_junction() -# -# Generates a junction element with a git repository -# -# Args: -# tmpdir: The tmpdir fixture, for storing the generated git repo -# subproject_path: The path for the subproject, to add to the git repo -# junction_path: The location to store the generated junction element -# store_ref: Whether to store the ref in the junction.bst file -# -# Returns: -# (str): The ref -# -def generate_junction(tmpdir, subproject_path, junction_path, *, store_ref=True): - # Create a repo to hold the subproject and generate - # a junction element for it - # - repo = create_repo('git', str(tmpdir)) - source_ref = ref = repo.create(subproject_path) - if not store_ref: - source_ref = None - - element = { - 'kind': 'junction', - 'sources': [ - repo.source_config(ref=source_ref) - ] - } - _yaml.dump(element, junction_path) - - return ref diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index 1ec8f491f..b9d833f24 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -2,12 +2,12 @@ import os import tarfile import hashlib import pytest -from tests.testutils import cli, create_repo, ALL_REPO_KINDS +from tests.testutils import cli, create_repo, ALL_REPO_KINDS, generate_junction from buildstream import _yaml from buildstream._exceptions import ErrorDomain, LoadErrorReason -from . import configure_project, generate_junction +from . import configure_project # Project directory DATA_DIR = os.path.join( diff --git a/tests/frontend/fetch.py b/tests/frontend/fetch.py index ee3a3c3d5..e896f4a67 100644 --- a/tests/frontend/fetch.py +++ b/tests/frontend/fetch.py @@ -1,11 +1,11 @@ import os import pytest -from tests.testutils import cli, create_repo, ALL_REPO_KINDS +from tests.testutils import cli, create_repo, ALL_REPO_KINDS, generate_junction from buildstream import _yaml from buildstream._exceptions import ErrorDomain, LoadErrorReason -from . import configure_project, generate_junction +from . import configure_project # Project directory TOP_DIR = os.path.dirname(os.path.realpath(__file__)) diff --git a/tests/frontend/pull.py b/tests/frontend/pull.py index 388aa103b..9d2d5d1a2 100644 --- a/tests/frontend/pull.py +++ b/tests/frontend/pull.py @@ -1,9 +1,8 @@ import os import shutil import pytest -from tests.testutils import cli, create_artifact_share +from tests.testutils import cli, create_artifact_share, generate_junction -from . import generate_junction # Project directory DATA_DIR = os.path.join( diff --git a/tests/frontend/push.py b/tests/frontend/push.py index be324ca53..6ee301e6d 100644 --- a/tests/frontend/push.py +++ b/tests/frontend/push.py @@ -3,7 +3,8 @@ import pytest from buildstream._exceptions import ErrorDomain from tests.testutils import cli, create_artifact_share, create_element_size -from . import configure_project, generate_junction +from tests.testutils import generate_junction +from . import configure_project # Project directory diff --git a/tests/frontend/show.py b/tests/frontend/show.py index 0276961ab..b21569426 100644 --- a/tests/frontend/show.py +++ b/tests/frontend/show.py @@ -1,12 +1,12 @@ import os import pytest import itertools -from tests.testutils import cli +from tests.testutils import cli, generate_junction from buildstream import _yaml from buildstream._exceptions import ErrorDomain, LoadErrorReason -from . import configure_project, generate_junction +from . import configure_project # Project directory DATA_DIR = os.path.join( diff --git a/tests/frontend/track.py b/tests/frontend/track.py index 51768d650..4e1059824 100644 --- a/tests/frontend/track.py +++ b/tests/frontend/track.py @@ -1,11 +1,11 @@ import os import pytest -from tests.testutils import cli, create_repo, ALL_REPO_KINDS +from tests.testutils import cli, create_repo, ALL_REPO_KINDS, generate_junction from buildstream._exceptions import ErrorDomain, LoadErrorReason from buildstream import _yaml -from . import configure_project, generate_junction +from . import configure_project # Project directory TOP_DIR = os.path.dirname(os.path.realpath(__file__)) diff --git a/tests/frontend/track_cross_junction.py b/tests/frontend/track_cross_junction.py index 34c39ddd2..423edbdef 100644 --- a/tests/frontend/track_cross_junction.py +++ b/tests/frontend/track_cross_junction.py @@ -1,10 +1,8 @@ import os import pytest -from tests.testutils import cli, create_repo, ALL_REPO_KINDS +from tests.testutils import cli, create_repo, ALL_REPO_KINDS, generate_junction from buildstream import _yaml -from . import generate_junction - def generate_element(repo, element_path, dep_name=None): element = { diff --git a/tests/testutils/__init__.py b/tests/testutils/__init__.py index 93143b505..e9db94989 100644 --- a/tests/testutils/__init__.py +++ b/tests/testutils/__init__.py @@ -2,3 +2,4 @@ from .runcli import cli, cli_integration from .repo import create_repo, ALL_REPO_KINDS from .artifactshare import create_artifact_share from .element_generators import create_element_size +from .junction import generate_junction diff --git a/tests/testutils/junction.py b/tests/testutils/junction.py new file mode 100644 index 000000000..efc429ef6 --- /dev/null +++ b/tests/testutils/junction.py @@ -0,0 +1,36 @@ +import os +from tests.testutils import create_repo +from buildstream import _yaml + + +# generate_junction() +# +# Generates a junction element with a git repository +# +# Args: +# tmpdir: The tmpdir fixture, for storing the generated git repo +# subproject_path: The path for the subproject, to add to the git repo +# junction_path: The location to store the generated junction element +# store_ref: Whether to store the ref in the junction.bst file +# +# Returns: +# (str): The ref +# +def generate_junction(tmpdir, subproject_path, junction_path, *, store_ref=True): + # Create a repo to hold the subproject and generate + # a junction element for it + # + repo = create_repo('git', str(tmpdir)) + source_ref = ref = repo.create(subproject_path) + if not store_ref: + source_ref = None + + element = { + 'kind': 'junction', + 'sources': [ + repo.source_config(ref=source_ref) + ] + } + _yaml.dump(element, junction_path) + + return ref |