This is an automated email from the ASF dual-hosted git repository. tvb pushed a commit to branch bschubert/standardize-source-tests in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 22d6093611ca15cb354d4751b1c97268df2be237 Author: Benjamin Schubert <[email protected]> AuthorDate: Wed Oct 14 07:41:40 2020 +0000 tests: Stop using the 'create_repo' utility, create them directly It is more context to know about and the 'create_repo' fixture doesn't do anything more than instanciating the class in our cases --- tests/elements/filter.py | 13 ++--- tests/format/include.py | 6 +-- tests/format/junctions.py | 11 +++-- tests/frontend/buildcheckout.py | 4 +- tests/frontend/cross_junction_workspace.py | 7 +-- tests/frontend/default_target.py | 7 +-- tests/frontend/logging.py | 9 ++-- tests/frontend/mirror.py | 24 ++++----- tests/frontend/order.py | 6 ++- tests/frontend/pull.py | 5 +- tests/frontend/track.py | 16 +++--- tests/sourcecache/fetch.py | 4 +- tests/sourcecache/push.py | 12 ++--- tests/sources/bzr.py | 5 +- tests/sources/git.py | 79 +++++++++++++++--------------- tests/sources/no_fetch_cached.py | 5 +- tests/testutils/element_generators.py | 5 +- tests/testutils/junction.py | 4 +- 18 files changed, 118 insertions(+), 104 deletions(-) diff --git a/tests/elements/filter.py b/tests/elements/filter.py index 443f64d..39c9431 100644 --- a/tests/elements/filter.py +++ b/tests/elements/filter.py @@ -6,11 +6,12 @@ import shutil import pytest -from buildstream.testing import create_repo from buildstream.testing import cli # pylint: disable=unused-import from buildstream.exceptions import ErrorDomain from buildstream import _yaml +from tests.testutils.repo.git import Git + DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "filter",) @@ -189,7 +190,7 @@ def test_filter_workspace_reset(datafiles, cli, tmpdir): @pytest.mark.datafiles(os.path.join(DATA_DIR, "basic")) def test_filter_track(datafiles, cli, tmpdir): - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(os.path.join(str(datafiles), "files")) elements_dir = os.path.join(str(tmpdir), "elements") project = str(tmpdir) @@ -235,7 +236,7 @@ def test_filter_track(datafiles, cli, tmpdir): @pytest.mark.datafiles(os.path.join(DATA_DIR, "basic")) def test_filter_track_excepted(datafiles, cli, tmpdir): - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(str(datafiles), "files")) elements_dir = os.path.join(str(tmpdir), "elements") project = str(tmpdir) @@ -280,7 +281,7 @@ def test_filter_track_excepted(datafiles, cli, tmpdir): @pytest.mark.datafiles(os.path.join(DATA_DIR, "basic")) def test_filter_track_multi_to_one(datafiles, cli, tmpdir): - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(os.path.join(str(datafiles), "files")) elements_dir = os.path.join(str(tmpdir), "elements") project = str(tmpdir) @@ -326,7 +327,7 @@ def test_filter_track_multi_to_one(datafiles, cli, tmpdir): @pytest.mark.datafiles(os.path.join(DATA_DIR, "basic")) def test_filter_track_multi(datafiles, cli, tmpdir): - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(os.path.join(str(datafiles), "files")) elements_dir = os.path.join(str(tmpdir), "elements") project = str(tmpdir) @@ -387,7 +388,7 @@ def test_filter_track_multi(datafiles, cli, tmpdir): @pytest.mark.datafiles(os.path.join(DATA_DIR, "basic")) def test_filter_track_multi_exclude(datafiles, cli, tmpdir): - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(os.path.join(str(datafiles), "files")) elements_dir = os.path.join(str(tmpdir), "elements") project = str(tmpdir) diff --git a/tests/format/include.py b/tests/format/include.py index 11659d4..e56a4f6 100644 --- a/tests/format/include.py +++ b/tests/format/include.py @@ -7,8 +7,8 @@ import pytest from buildstream import _yaml from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing import cli # pylint: disable=unused-import -from buildstream.testing import create_repo from tests.testutils import generate_junction +from tests.testutils.repo.git import Git # Project directory @@ -109,7 +109,7 @@ def test_junction_element_partial_project_project(cli, tmpdir, datafiles): subproject_path = os.path.join(project, "subproject") junction_path = os.path.join(project, "junction.bst") - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(subproject_path) @@ -133,7 +133,7 @@ def test_junction_element_not_partial_project_file(cli, tmpdir, datafiles): subproject_path = os.path.join(project, "subproject") junction_path = os.path.join(project, "junction.bst") - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(subproject_path) diff --git a/tests/format/junctions.py b/tests/format/junctions.py index c4eea2d..2a34068 100644 --- a/tests/format/junctions.py +++ b/tests/format/junctions.py @@ -8,7 +8,8 @@ import pytest from buildstream import _yaml from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing import cli # pylint: disable=unused-import -from buildstream.testing import create_repo + +from tests.testutils.repo.tar import Tar DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "junctions",) @@ -260,7 +261,7 @@ def test_tar_show(cli, tmpdir, datafiles): project = os.path.join(str(datafiles), "use-repo") # Create the repo from 'baserepo' subdir - repo = create_repo("tar", str(tmpdir)) + repo = Tar(str(tmpdir)) ref = repo.create(os.path.join(project, "baserepo")) # Write out junction element with tar source @@ -279,7 +280,7 @@ def test_tar_build(cli, tmpdir, datafiles): checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the repo from 'baserepo' subdir - repo = create_repo("tar", str(tmpdir)) + repo = Tar(str(tmpdir)) ref = repo.create(os.path.join(project, "baserepo")) # Write out junction element with tar source @@ -304,7 +305,7 @@ def test_tar_missing_project_conf(cli, tmpdir, datafiles): os.remove(datafiles / "use-repo" / "baserepo" / "project.conf") # Create the repo from 'base' subdir - repo = create_repo("tar", str(tmpdir)) + repo = Tar(str(tmpdir)) ref = repo.create(os.path.join(project, "baserepo")) # Write out junction element with tar source @@ -324,7 +325,7 @@ def test_build_tar_cross_junction_names(cli, tmpdir, datafiles): checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the repo from 'base' subdir - repo = create_repo("tar", str(tmpdir)) + repo = Tar(str(tmpdir)) ref = repo.create(os.path.join(project, "baserepo")) # Write out junction element with tar source diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index 5afa521..48b649c 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -9,13 +9,13 @@ import re import pytest from buildstream.testing import cli # pylint: disable=unused-import -from buildstream.testing import create_repo from buildstream.testing._utils.site import IS_WINDOWS, CASD_SEPARATE_USER from buildstream import _yaml from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream import utils from tests.testutils import generate_junction, create_artifact_share +from tests.testutils.repo.git import Git from . import configure_project @@ -1069,7 +1069,7 @@ def test_partial_artifact_checkout_fetch(cli, datafiles, tmpdir): project = str(datafiles) checkout_dir = os.path.join(str(tmpdir), "checkout") - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(str(datafiles), "files")) element_dir = os.path.join(str(tmpdir), "elements") project = str(tmpdir) diff --git a/tests/frontend/cross_junction_workspace.py b/tests/frontend/cross_junction_workspace.py index c3b80ae..f1d344f 100644 --- a/tests/frontend/cross_junction_workspace.py +++ b/tests/frontend/cross_junction_workspace.py @@ -3,9 +3,10 @@ import os from buildstream.testing import cli # pylint: disable=unused-import -from buildstream.testing import create_repo from buildstream import _yaml +from tests.testutils.repo.git import Git + def prepare_junction_project(cli, tmpdir): main_project = tmpdir.join("main") @@ -23,7 +24,7 @@ def prepare_junction_project(cli, tmpdir): import_repo_dir = tmpdir.join("import_repo") os.makedirs(str(import_repo_dir)) - import_repo = create_repo("git", str(import_repo_dir)) + import_repo = Git(str(import_repo_dir)) import_ref = import_repo.create(str(import_dir)) _yaml.roundtrip_dump( @@ -32,7 +33,7 @@ def prepare_junction_project(cli, tmpdir): sub_repo_dir = tmpdir.join("sub_repo") os.makedirs(str(sub_repo_dir)) - sub_repo = create_repo("git", str(sub_repo_dir)) + sub_repo = Git(str(sub_repo_dir)) sub_ref = sub_repo.create(str(sub_project)) _yaml.roundtrip_dump( diff --git a/tests/frontend/default_target.py b/tests/frontend/default_target.py index bb7a495..828a25f 100644 --- a/tests/frontend/default_target.py +++ b/tests/frontend/default_target.py @@ -6,8 +6,9 @@ import os import pytest from buildstream import _yaml -from buildstream.testing import cli, create_repo # pylint: disable=unused-import +from buildstream.testing import cli # pylint: disable=unused-import from tests.testutils import create_artifact_share +from tests.testutils.repo.git import Git # project directory DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "default-target",) @@ -95,7 +96,7 @@ def test_default_target_track(cli, tmpdir, datafiles): target = "track-fetch-test.bst" # First, create an element with trackable sources - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(project) element_conf = {"kind": "import", "sources": [repo.source_config()]} _yaml.roundtrip_dump(element_conf, os.path.join(project, "elements", target)) @@ -125,7 +126,7 @@ def test_default_target_fetch(cli, tmpdir, datafiles): target = "track-fetch-test.bst" # First, create an element with trackable sources - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(project) element_conf = {"kind": "import", "sources": [repo.source_config(ref=ref)]} _yaml.roundtrip_dump(element_conf, os.path.join(project, "elements", target)) diff --git a/tests/frontend/logging.py b/tests/frontend/logging.py index 6eb0589..5811e0f 100644 --- a/tests/frontend/logging.py +++ b/tests/frontend/logging.py @@ -6,12 +6,13 @@ import re import pytest -from buildstream.testing import create_repo - from buildstream import _yaml from buildstream.exceptions import ErrorDomain from buildstream.testing import cli # pylint: disable=unused-import +from tests.testutils.repo.git import Git + + # Project directory DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",) @@ -26,7 +27,7 @@ def test_default_logging(cli, tmpdir, datafiles): # Create our repo object of the given source type with # the bin files, and then collect the initial ref. # - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(bin_files_path) # Write out our test target @@ -55,7 +56,7 @@ def test_custom_logging(cli, tmpdir, datafiles): # Create our repo object of the given source type with # the bin files, and then collect the initial ref. # - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(bin_files_path) # Write out our test target diff --git a/tests/frontend/mirror.py b/tests/frontend/mirror.py index bffc754..4884ef3 100644 --- a/tests/frontend/mirror.py +++ b/tests/frontend/mirror.py @@ -5,9 +5,11 @@ import os import pytest from buildstream import _yaml -from buildstream.testing import create_repo from buildstream.testing import cli # pylint: disable=unused-import +from tests.testutils.repo.git import Git +from tests.testutils.repo.tar import Tar + # Project directory TOP_DIR = os.path.dirname(os.path.realpath(__file__)) @@ -67,7 +69,7 @@ def test_mirror_fetch_ref_storage(cli, tmpdir, datafiles, ref_storage, mirror): element_dir = os.path.join(project_dir, "elements") # Create repo objects of the upstream and mirror - upstream_repo = create_repo("tar", upstream_repodir) + upstream_repo = Tar(upstream_repodir) upstream_repo.create(bin_files_path) mirror_repo = upstream_repo.copy(mirror_repodir) upstream_ref = upstream_repo.create(dev_files_path) @@ -247,15 +249,15 @@ def test_mirror_git_submodule_fetch(cli, tmpdir, datafiles): dev_files_path = os.path.join(str(datafiles), "files", "dev-files", "usr") mirror_dir = os.path.join(str(datafiles), "mirror") - defined_subrepo = create_repo("git", str(tmpdir), "defined_subrepo") + defined_subrepo = Git(str(tmpdir), "defined_subrepo") defined_subrepo.create(bin_files_path) defined_subrepo.copy(mirror_dir) defined_subrepo.add_file(foo_file) - found_subrepo = create_repo("git", str(tmpdir), "found_subrepo") + found_subrepo = Git(str(tmpdir), "found_subrepo") found_subrepo.create(dev_files_path) - main_repo = create_repo("git", str(tmpdir)) + main_repo = Git(str(tmpdir)) main_mirror_ref = main_repo.create(bin_files_path) main_repo.add_submodule("defined", "file://" + defined_subrepo.repo) main_repo.add_submodule("found", "file://" + found_subrepo.repo) @@ -320,12 +322,12 @@ def test_mirror_fallback_git_only_submodules(cli, tmpdir, datafiles): upstream_bin_repodir = os.path.join(str(tmpdir), "bin-upstream") mirror_bin_repodir = os.path.join(str(tmpdir), "bin-mirror") - upstream_bin_repo = create_repo("git", upstream_bin_repodir) + upstream_bin_repo = Git(upstream_bin_repodir) upstream_bin_repo.create(bin_files_path) mirror_bin_repo = upstream_bin_repo.copy(mirror_bin_repodir) dev_repodir = os.path.join(str(tmpdir), "dev-upstream") - dev_repo = create_repo("git", dev_repodir) + dev_repo = Git(dev_repodir) dev_repo.create(dev_files_path) main_files = os.path.join(str(tmpdir), "main-files") @@ -333,7 +335,7 @@ def test_mirror_fallback_git_only_submodules(cli, tmpdir, datafiles): with open(os.path.join(main_files, "README"), "w") as f: f.write("TEST\n") main_repodir = os.path.join(str(tmpdir), "main-upstream") - main_repo = create_repo("git", main_repodir) + main_repo = Git(main_repodir) main_repo.create(main_files) upstream_url = "file://{}".format(upstream_bin_repo.repo) @@ -399,11 +401,11 @@ def test_mirror_fallback_git_with_submodules(cli, tmpdir, datafiles): dev_files_path = os.path.join(str(datafiles), "files", "dev-files", "usr") bin_repodir = os.path.join(str(tmpdir), "bin-repo") - bin_repo = create_repo("git", bin_repodir) + bin_repo = Git(bin_repodir) bin_repo.create(bin_files_path) dev_repodir = os.path.join(str(tmpdir), "dev-repo") - dev_repo = create_repo("git", dev_repodir) + dev_repo = Git(dev_repodir) dev_repo.create(dev_files_path) main_files = os.path.join(str(tmpdir), "main-files") @@ -411,7 +413,7 @@ def test_mirror_fallback_git_with_submodules(cli, tmpdir, datafiles): with open(os.path.join(main_files, "README"), "w") as f: f.write("TEST\n") upstream_main_repodir = os.path.join(str(tmpdir), "main-upstream") - upstream_main_repo = create_repo("git", upstream_main_repodir) + upstream_main_repo = Git(upstream_main_repodir) upstream_main_repo.create(main_files) upstream_main_repo.add_submodule("bin", url="file://{}".format(bin_repo.repo)) diff --git a/tests/frontend/order.py b/tests/frontend/order.py index fbeb7c3..47b6303 100644 --- a/tests/frontend/order.py +++ b/tests/frontend/order.py @@ -4,10 +4,12 @@ import os import pytest -from buildstream.testing import create_repo from buildstream.testing import cli # pylint: disable=unused-import from buildstream import _yaml +from tests.testutils.repo.git import Git + + # Project directory DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",) @@ -24,7 +26,7 @@ DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",) def create_element(project, name, dependencies): dev_files_path = os.path.join(project, "files", "dev-files") element_path = os.path.join(project, "elements") - repo = create_repo("git", project, "{}-repo".format(name)) + repo = Git(project, "{}-repo".format(name)) ref = repo.create(dev_files_path) element = {"kind": "import", "sources": [repo.source_config(ref=ref)], "depends": dependencies} diff --git a/tests/frontend/pull.py b/tests/frontend/pull.py index c1fa76a..dca3916 100644 --- a/tests/frontend/pull.py +++ b/tests/frontend/pull.py @@ -7,7 +7,6 @@ import stat import pytest from buildstream import utils, _yaml from buildstream.testing import cli # pylint: disable=unused-import -from buildstream.testing import create_repo from tests.testutils import ( create_artifact_share, create_split_share, @@ -15,7 +14,7 @@ from tests.testutils import ( assert_shared, assert_not_shared, ) - +from tests.testutils.repo.git import Git # Project directory DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",) @@ -318,7 +317,7 @@ def test_pull_missing_blob_split_share(cli, tmpdir, datafiles): @pytest.mark.datafiles(DATA_DIR) def test_pull_missing_local_blob(cli, tmpdir, datafiles): project = os.path.join(datafiles.dirname, datafiles.basename) - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(str(datafiles), "files")) element_dir = os.path.join(str(tmpdir), "elements") project = str(tmpdir) diff --git a/tests/frontend/track.py b/tests/frontend/track.py index 682ee0e..7d7fcbd 100644 --- a/tests/frontend/track.py +++ b/tests/frontend/track.py @@ -6,11 +6,13 @@ import os import re import pytest -from buildstream.testing import create_repo, generate_project +from buildstream.testing import generate_project from buildstream.testing import cli # pylint: disable=unused-import from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream import _yaml from tests.testutils import generate_junction +from tests.testutils.repo.git import Git +from tests.testutils.repo.tar import Tar from . import configure_project # Project directory @@ -37,7 +39,7 @@ def test_track_single(cli, tmpdir, datafiles): # Create our repo object of the given source type with # the dev files, and then collect the initial ref. # - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(dev_files_path) # Write out our test targets @@ -77,7 +79,7 @@ def test_track_optional(cli, tmpdir, datafiles, ref_storage): # Create our repo object of the given source type with # the dev files, and then collect the initial ref. # - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(dev_files_path) # Now create an optional test branch and add a commit to that, @@ -174,7 +176,7 @@ def test_track_cross_junction(cli, tmpdir, datafiles, cross_junction, ref_storag # Create our repo object of the given source type with # the dev files, and then collect the initial ref. # - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(dev_files_path) # Generate two elements using the git source, one in @@ -341,7 +343,7 @@ def test_track_error_cannot_write_file(cli, tmpdir, datafiles): configure_project(project, {"ref-storage": "inline"}) - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(dev_files_path) element_full_path = os.path.join(element_path, element_name) @@ -369,7 +371,7 @@ def test_no_needless_overwrite(cli, tmpdir, datafiles): # Create our repo object of the given source type with # the dev files, and then collect the initial ref. # - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(dev_files_path) # Write out our test target and assert it exists @@ -456,7 +458,7 @@ def test_track_skip(cli, tmpdir, datafiles): # Generate a regular import element which will have a workspace open # - repo = create_repo("tar", str(tmpdir)) + repo = Tar(str(tmpdir)) repo.create(dev_files_path) generate_element(repo, os.path.join(element_path, element_workspace_name)) diff --git a/tests/sourcecache/fetch.py b/tests/sourcecache/fetch.py index 76f5508..0eef6b7 100644 --- a/tests/sourcecache/fetch.py +++ b/tests/sourcecache/fetch.py @@ -28,15 +28,15 @@ from buildstream.exceptions import ErrorDomain from buildstream._project import Project from buildstream import _yaml from buildstream.testing import cli # pylint: disable=unused-import -from buildstream.testing import create_repo from tests.testutils import create_artifact_share, dummy_context +from tests.testutils.repo.git import Git DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project") def create_test_element(tmpdir, project_dir): - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(os.path.join(project_dir, "files")) element_path = os.path.join(project_dir, "elements") element_name = "fetch.bst" diff --git a/tests/sourcecache/push.py b/tests/sourcecache/push.py index 25a4309..eaae9e7 100644 --- a/tests/sourcecache/push.py +++ b/tests/sourcecache/push.py @@ -29,8 +29,8 @@ from buildstream.exceptions import ErrorDomain from buildstream._project import Project from buildstream import _yaml from buildstream.testing import cli # pylint: disable=unused-import -from buildstream.testing import create_repo from tests.testutils import create_artifact_share, dummy_context +from tests.testutils.repo.git import Git DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project") @@ -71,7 +71,7 @@ def test_source_push_split(cli, tmpdir, datafiles): _yaml.roundtrip_dump(user_config, file=user_config_file) cli.configure(user_config) - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(os.path.join(project_dir, "files")) element_path = os.path.join(project_dir, "elements") element_name = "push.bst" @@ -121,7 +121,7 @@ def test_source_push(cli, tmpdir, datafiles): _yaml.roundtrip_dump(user_config, file=user_config_file) cli.configure(user_config) - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(os.path.join(project_dir, "files")) element_path = os.path.join(project_dir, "elements") element_name = "push.bst" @@ -172,7 +172,7 @@ def test_push_pull(cli, datafiles, tmpdir): cli.configure(user_config) # create repo to pull from - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(os.path.join(project_dir, "files")) element_path = os.path.join(project_dir, "elements") element_name = "push.bst" @@ -210,7 +210,7 @@ def test_push_fail(cli, tmpdir, datafiles): cli.configure(user_config) # create repo to pull from - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(os.path.join(project_dir, "files")) element_path = os.path.join(project_dir, "elements") element_name = "push.bst" @@ -239,7 +239,7 @@ def test_source_push_build_fail(cli, tmpdir, datafiles): } cli.configure(user_config) - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(os.path.join(project_dir, "files")) element_path = os.path.join(project_dir, "elements") diff --git a/tests/sources/bzr.py b/tests/sources/bzr.py index 2dcacfe..37e6dc3 100644 --- a/tests/sources/bzr.py +++ b/tests/sources/bzr.py @@ -5,10 +5,11 @@ import os import pytest from buildstream.testing import cli # pylint: disable=unused-import -from buildstream.testing import create_repo from buildstream.testing import generate_element from buildstream.testing._utils.site import HAVE_BZR +from tests.testutils.repo.bzr import Bzr + DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "bzr") @@ -18,7 +19,7 @@ def test_fetch_checkout(cli, tmpdir, datafiles): project = str(datafiles) checkoutdir = os.path.join(str(tmpdir), "checkout") - repo = create_repo("bzr", str(tmpdir)) + repo = Bzr(str(tmpdir)) ref = repo.create(os.path.join(project, "basic")) # Write out our test target diff --git a/tests/sources/git.py b/tests/sources/git.py index 30657d8..22b87ea 100644 --- a/tests/sources/git.py +++ b/tests/sources/git.py @@ -34,9 +34,10 @@ from buildstream.exceptions import ErrorDomain from buildstream.plugin import CoreWarnings from buildstream.testing import cli # pylint: disable=unused-import from buildstream.testing import generate_project, generate_element, load_yaml -from buildstream.testing import create_repo from buildstream.testing._utils.site import HAVE_GIT, HAVE_OLD_GIT +from tests.testutils.repo.git import Git + DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "git",) @@ -46,7 +47,7 @@ def test_fetch_bad_ref(cli, tmpdir, datafiles): project = str(datafiles) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(project, "repofiles")) # Write out our test target with a bad ref @@ -67,7 +68,7 @@ def test_fetch_shallow(cli, tmpdir, datafiles): workspacedir = os.path.join(str(tmpdir), "workspace") # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(project, "repofiles")) first_commit = repo.latest_commit() repo.add_commit() @@ -94,11 +95,11 @@ def test_submodule_fetch_checkout(cli, tmpdir, datafiles): checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the submodule first from the 'subrepofiles' subdir - subrepo = create_repo("git", str(tmpdir), "subrepo") + subrepo = Git(str(tmpdir), "subrepo") subrepo.create(os.path.join(project, "subrepofiles")) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(project, "repofiles")) # Add a submodule pointing to the one we created @@ -128,15 +129,15 @@ def test_recursive_submodule_fetch_checkout(cli, tmpdir, datafiles): checkoutdir = os.path.join(str(tmpdir), "checkout") # Create a submodule from the 'othersubrepofiles' subdir - subsubrepo = create_repo("git", str(tmpdir), "subsubrepo") + subsubrepo = Git(str(tmpdir), "subsubrepo") subsubrepo.create(os.path.join(project, "othersubrepofiles")) # Create another submodule from the 'subrepofiles' subdir - subrepo = create_repo("git", str(tmpdir), "subrepo") + subrepo = Git(str(tmpdir), "subrepo") subrepo.create(os.path.join(project, "subrepofiles")) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(project, "repofiles")) # Configure submodules @@ -168,11 +169,11 @@ def test_submodule_fetch_source_enable_explicit(cli, tmpdir, datafiles): checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the submodule first from the 'subrepofiles' subdir - subrepo = create_repo("git", str(tmpdir), "subrepo") + subrepo = Git(str(tmpdir), "subrepo") subrepo.create(os.path.join(project, "subrepofiles")) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(project, "repofiles")) # Add a submodule pointing to the one we created @@ -202,11 +203,11 @@ def test_submodule_fetch_source_disable(cli, tmpdir, datafiles): checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the submodule first from the 'subrepofiles' subdir - subrepo = create_repo("git", str(tmpdir), "subrepo") + subrepo = Git(str(tmpdir), "subrepo") subrepo.create(os.path.join(project, "subrepofiles")) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(project, "repofiles")) # Add a submodule pointing to the one we created @@ -236,11 +237,11 @@ def test_submodule_fetch_submodule_does_override(cli, tmpdir, datafiles): checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the submodule first from the 'subrepofiles' subdir - subrepo = create_repo("git", str(tmpdir), "subrepo") + subrepo = Git(str(tmpdir), "subrepo") subrepo.create(os.path.join(project, "subrepofiles")) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(project, "repofiles")) # Add a submodule pointing to the one we created @@ -270,15 +271,15 @@ def test_submodule_fetch_submodule_individual_checkout(cli, tmpdir, datafiles): checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the submodule first from the 'subrepofiles' subdir - subrepo = create_repo("git", str(tmpdir), "subrepo") + subrepo = Git(str(tmpdir), "subrepo") subrepo.create(os.path.join(project, "subrepofiles")) # Create another submodule from the 'othersubrepofiles' subdir - other_subrepo = create_repo("git", str(tmpdir), "othersubrepo") + other_subrepo = Git(str(tmpdir), "othersubrepo") other_subrepo.create(os.path.join(project, "othersubrepofiles")) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(project, "repofiles")) # Add a submodule pointing to the one we created @@ -310,15 +311,15 @@ def test_submodule_fetch_submodule_individual_checkout_explicit(cli, tmpdir, dat checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the submodule first from the 'subrepofiles' subdir - subrepo = create_repo("git", str(tmpdir), "subrepo") + subrepo = Git(str(tmpdir), "subrepo") subrepo.create(os.path.join(project, "subrepofiles")) # Create another submodule from the 'othersubrepofiles' subdir - other_subrepo = create_repo("git", str(tmpdir), "othersubrepo") + other_subrepo = Git(str(tmpdir), "othersubrepo") other_subrepo.create(os.path.join(project, "othersubrepofiles")) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(project, "repofiles")) # Add a submodule pointing to the one we created @@ -350,11 +351,11 @@ def test_submodule_fetch_project_override(cli, tmpdir, datafiles): checkoutdir = os.path.join(str(tmpdir), "checkout") # Create the submodule first from the 'subrepofiles' subdir - subrepo = create_repo("git", str(tmpdir), "subrepo") + subrepo = Git(str(tmpdir), "subrepo") subrepo.create(os.path.join(project, "subrepofiles")) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(project, "repofiles")) # Add a submodule pointing to the one we created @@ -383,7 +384,7 @@ def test_submodule_track_ignore_inconsistent(cli, tmpdir, datafiles): project = str(datafiles) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(os.path.join(project, "repofiles")) # Write out our test target @@ -415,7 +416,7 @@ def test_submodule_track_no_ref_or_track(cli, tmpdir, datafiles): project = str(datafiles) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(project, "repofiles")) # Write out our test target @@ -441,7 +442,7 @@ def test_ref_not_in_track(cli, tmpdir, datafiles, fail): generate_project(project, config={"fatal-warnings": [CoreWarnings.REF_NOT_IN_TRACK]}) # Create the repo from 'repofiles', create a branch without latest commit - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(os.path.join(project, "repofiles")) gitsource = repo.source_config(ref=ref) @@ -475,11 +476,11 @@ def test_unlisted_submodule(cli, tmpdir, datafiles, fail): generate_project(project, config={"fatal-warnings": ["git:unlisted-submodule"]}) # Create the submodule first from the 'subrepofiles' subdir - subrepo = create_repo("git", str(tmpdir), "subrepo") + subrepo = Git(str(tmpdir), "subrepo") subrepo.create(os.path.join(project, "subrepofiles")) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(project, "repofiles")) # Add a submodule pointing to the one we created @@ -533,11 +534,11 @@ def test_track_unlisted_submodule(cli, tmpdir, datafiles, fail): generate_project(project, config={"fatal-warnings": ["git:unlisted-submodule"]}) # Create the submodule first from the 'subrepofiles' subdir - subrepo = create_repo("git", str(tmpdir), "subrepo") + subrepo = Git(str(tmpdir), "subrepo") subrepo.create(os.path.join(project, "subrepofiles")) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(os.path.join(project, "repofiles")) # Add a submodule pointing to the one we created, but use @@ -587,7 +588,7 @@ def test_invalid_submodule(cli, tmpdir, datafiles, fail): generate_project(project, config={"fatal-warnings": ["git:invalid-submodule"]}) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(os.path.join(project, "repofiles")) # Create the source without any submodules, and add @@ -640,11 +641,11 @@ def test_track_invalid_submodule(cli, tmpdir, datafiles, fail): generate_project(project, config={"fatal-warnings": ["git:invalid-submodule"]}) # Create the submodule first from the 'subrepofiles' subdir - subrepo = create_repo("git", str(tmpdir), "subrepo") + subrepo = Git(str(tmpdir), "subrepo") subrepo.create(os.path.join(project, "subrepofiles")) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(project, "repofiles")) # Add a submodule pointing to the one we created @@ -691,7 +692,7 @@ def test_track_fetch(cli, tmpdir, datafiles, ref_format, tag, extra_commit): project = str(datafiles) # Create the repo from 'repofiles' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(os.path.join(project, "repofiles")) if tag: repo.add_tag("tag") @@ -743,7 +744,7 @@ def test_git_describe(cli, tmpdir, datafiles, ref_storage, tag_type): with open(file0, "w") as f: f.write("test\n") - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) def tag(name): if tag_type == "annotated": @@ -853,7 +854,7 @@ def test_git_describe_head_is_tagged(cli, tmpdir, datafiles, ref_storage, tag_ty with open(file0, "w") as f: f.write("test\n") - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) def tag(name): if tag_type == "annotated": @@ -960,7 +961,7 @@ def test_git_describe_relevant_history(cli, tmpdir, datafiles): with open(file0, "w") as f: f.write("test\n") - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(repofiles) file1 = os.path.join(str(tmpdir), "file1") @@ -1033,7 +1034,7 @@ def test_default_do_not_track_tags(cli, tmpdir, datafiles): with open(file0, "w") as f: f.write("test\n") - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) repo.create(repofiles) repo.add_tag("tag") @@ -1073,7 +1074,7 @@ def test_overwrite_rogue_tag_multiple_remotes(cli, tmpdir, datafiles): with open(file0, "w") as f: f.write("test\n") - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) top_commit = repo.create(repofiles) @@ -1119,7 +1120,7 @@ def test_overwrite_rogue_tag_multiple_remotes(cli, tmpdir, datafiles): otherpath = os.path.join(str(tmpdir), "other_path") shutil.copytree(repo.repo, os.path.join(otherpath, "repo")) - create_repo("git", otherpath) + Git(otherpath) repodir, reponame = os.path.split(repo.repo) diff --git a/tests/sources/no_fetch_cached.py b/tests/sources/no_fetch_cached.py index 4984f53..ece0ca3 100644 --- a/tests/sources/no_fetch_cached.py +++ b/tests/sources/no_fetch_cached.py @@ -5,10 +5,11 @@ import os import pytest from buildstream.testing import cli # pylint: disable=unused-import -from buildstream.testing import create_repo from buildstream.testing import generate_element from buildstream.testing._utils.site import HAVE_GIT +from tests.testutils.repo.git import Git + DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "no-fetch-cached") @@ -22,7 +23,7 @@ def test_no_fetch_cached(cli, tmpdir, datafiles): project = str(datafiles) # Create the repo from 'files' subdir - repo = create_repo("git", str(tmpdir)) + repo = Git(str(tmpdir)) ref = repo.create(os.path.join(project, "files")) # Write out test target with a cached and a non-cached source diff --git a/tests/testutils/element_generators.py b/tests/testutils/element_generators.py index 6da465a..5b0a922 100644 --- a/tests/testutils/element_generators.py +++ b/tests/testutils/element_generators.py @@ -2,7 +2,8 @@ import os from buildstream import _yaml from buildstream import utils -from buildstream.testing import create_repo + +from .repo.git import Git # create_element_size() @@ -29,7 +30,7 @@ def create_element_size(name, project_dir, elements_path, dependencies, size): # Create a git repo repodir = os.path.join(project_dir, "repos") - repo = create_repo("git", repodir, subdir=name) + repo = Git(repodir, subdir=name) with utils._tempdir(dir=project_dir) as tmp: diff --git a/tests/testutils/junction.py b/tests/testutils/junction.py index 4889fdb..856ea5c 100644 --- a/tests/testutils/junction.py +++ b/tests/testutils/junction.py @@ -1,6 +1,6 @@ from buildstream import _yaml -from buildstream.testing import create_repo +from tests.testutils.repo.git import Git # generate_junction() # @@ -19,7 +19,7 @@ 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)) + repo = Git(str(tmpdir)) source_ref = ref = repo.create(subproject_path) if not store_ref: source_ref = None
