You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:13:46 UTC

[buildstream] 01/30: Move tests.frontend.generate_junction to test.testutils

This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch valentindavid/flatpak-demo
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 2eaff21f162e4b779e57132a477f582e424445d3
Author: Valentin David <va...@codethink.co.uk>
AuthorDate: Mon Jun 11 15:33:11 2018 +0200

    Move tests.frontend.generate_junction to test.testutils
---
 tests/frontend/__init__.py                         | 34 ----------------------
 tests/frontend/buildcheckout.py                    |  4 +--
 tests/frontend/fetch.py                            |  4 +--
 tests/frontend/pull.py                             |  3 +-
 tests/frontend/push.py                             |  4 +--
 tests/frontend/show.py                             |  4 +--
 tests/frontend/track.py                            |  4 +--
 tests/frontend/track_cross_junction.py             |  4 +--
 tests/testutils/__init__.py                        |  1 +
 .../__init__.py => testutils/junction.py}          |  8 -----
 10 files changed, 13 insertions(+), 57 deletions(-)

diff --git a/tests/frontend/__init__.py b/tests/frontend/__init__.py
index 2eadf15..8cf7625 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 5b46d3d..a65365e 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.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
 DATA_DIR = os.path.join(
diff --git a/tests/frontend/fetch.py b/tests/frontend/fetch.py
index ee3a3c3..e896f4a 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 c43cc83..d7b5a60 100644
--- a/tests/frontend/pull.py
+++ b/tests/frontend/pull.py
@@ -1,10 +1,9 @@
 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 tests.testutils.site import IS_LINUX
 
-from . import generate_junction
 
 # Project directory
 DATA_DIR = os.path.join(
diff --git a/tests/frontend/push.py b/tests/frontend/push.py
index ca46b04..f76a6c4 100644
--- a/tests/frontend/push.py
+++ b/tests/frontend/push.py
@@ -5,9 +5,9 @@ from collections import namedtuple
 from unittest.mock import MagicMock
 
 from buildstream._exceptions import ErrorDomain
-from tests.testutils import cli, create_artifact_share, create_element_size
+from tests.testutils import cli, create_artifact_share, create_element_size, generate_junction
 from tests.testutils.site import IS_LINUX
-from . import configure_project, generate_junction
+from . import configure_project
 
 
 # Project directory
diff --git a/tests/frontend/show.py b/tests/frontend/show.py
index 0276961..b215694 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 51768d6..4e10598 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 34c39dd..423edbd 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 93143b5..e9db949 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/frontend/__init__.py b/tests/testutils/junction.py
similarity index 81%
copy from tests/frontend/__init__.py
copy to tests/testutils/junction.py
index 2eadf15..efc429e 100644
--- a/tests/frontend/__init__.py
+++ b/tests/testutils/junction.py
@@ -3,14 +3,6 @@ from tests.testutils import create_repo
 from buildstream import _yaml
 
 
-# Shared function to configure the project.conf inline
-#
-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