Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop testing workspace tests with any kind, and use specific kinds instead #1572

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions tests/frontend/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@

import pytest

from buildstream.testing import create_repo, ALL_REPO_KINDS
from buildstream.testing import create_repo
from buildstream.testing import cli # pylint: disable=unused-import
from buildstream import _yaml
from buildstream.exceptions import ErrorDomain, LoadErrorReason
from buildstream._workspaces import BST_WORKSPACE_FORMAT_VERSION

from tests.testutils import create_artifact_share, create_element_size, wait_for_cache_granularity

repo_kinds = ALL_REPO_KINDS

# Project directory
DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
Expand Down Expand Up @@ -170,10 +169,13 @@ def open_workspace(
@pytest.mark.datafiles(DATA_DIR)
def test_open_multi(cli, tmpdir, datafiles):
workspace_object = WorkspaceCreator(cli, tmpdir, datafiles)
workspaces = workspace_object.open_workspaces(repo_kinds)
kinds = ["tar"] * 2
suffixs = range(2)

for (elname, workspace), kind in zip(workspaces, repo_kinds):
assert kind in elname
workspaces = workspace_object.open_workspaces(kinds, suffixs)

for (elname, workspace), kind, suffix in zip(workspaces, kinds, suffixs):
assert "{}{}".format(kind, suffix) in elname
workspace_lsdir = os.listdir(workspace)
assert elname in workspace_lsdir

Expand All @@ -182,8 +184,10 @@ def test_open_multi(cli, tmpdir, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_open_multi_unwritable(cli, tmpdir, datafiles):
workspace_object = WorkspaceCreator(cli, tmpdir, datafiles)
kinds = ["tar"] * 2
suffixs = range(2)

element_tuples = workspace_object.create_workspace_elements(repo_kinds, repo_kinds)
element_tuples = workspace_object.create_workspace_elements(kinds, suffixs)
os.makedirs(workspace_object.workspace_cmd, exist_ok=True)

# Now open the workspace, this should have the effect of automatically
Expand All @@ -209,8 +213,10 @@ def test_open_multi_unwritable(cli, tmpdir, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_open_multi_with_directory(cli, tmpdir, datafiles):
workspace_object = WorkspaceCreator(cli, tmpdir, datafiles)
kinds = ["tar"] * 2
suffixs = range(2)

element_tuples = workspace_object.create_workspace_elements(repo_kinds, repo_kinds)
element_tuples = workspace_object.create_workspace_elements(kinds, suffixs)
os.makedirs(workspace_object.workspace_cmd, exist_ok=True)

# Now open the workspace, this should have the effect of automatically
Expand Down Expand Up @@ -636,16 +642,15 @@ def test_list(cli, tmpdir, datafiles):


@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("kind", repo_kinds)
@pytest.mark.parametrize("strict", [("strict"), ("non-strict")])
@pytest.mark.parametrize(
"from_workspace,guess_element",
[(False, False), (True, True), (True, False)],
ids=["project-no-guess", "workspace-guess", "workspace-no-guess"],
)
def test_build(cli, tmpdir_factory, datafiles, kind, strict, from_workspace, guess_element):
def test_build(cli, tmpdir_factory, datafiles, strict, from_workspace, guess_element):
tmpdir = tmpdir_factory.mktemp(BASE_FILENAME)
element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False)
element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "tar", False)
checkout = os.path.join(str(tmpdir), "checkout")
args_dir = ["-C", workspace] if from_workspace else []
args_elm = [element_name] if not guess_element else []
Expand Down