summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2020-10-08 21:30:06 +0000
committerBenjamin Schubert <1593324-BenjaminSchubert@users.noreply.gitlab.com>2020-10-26 14:22:00 +0000
commit4eaf1ba5ae52d722b9413af0fc0f9285ea0ae886 (patch)
tree25b6697ae85ef0563c156cb09e9bc6b5cacf6254
parentdf68855147c8bdc6b863ef9e4daec52a3c8cfe52 (diff)
downloadbuildstream-4eaf1ba5ae52d722b9413af0fc0f9285ea0ae886.tar.gz
workspace.py: Remove arguments that are unused during the test
-rw-r--r--src/buildstream/testing/_sourcetests/workspace.py46
1 files changed, 15 insertions, 31 deletions
diff --git a/src/buildstream/testing/_sourcetests/workspace.py b/src/buildstream/testing/_sourcetests/workspace.py
index 7f3c5dea4..ebc03c97d 100644
--- a/src/buildstream/testing/_sourcetests/workspace.py
+++ b/src/buildstream/testing/_sourcetests/workspace.py
@@ -20,7 +20,6 @@
# pylint: disable=redefined-outer-name
import os
-import shutil
import pytest
from buildstream import _yaml
@@ -34,28 +33,20 @@ DATA_DIR = os.path.join(TOP_DIR, "project")
class WorkspaceCreator:
- def __init__(self, cli, tmpdir, datafiles, project_path=None):
+ def __init__(self, cli, tmpdir, datafiles):
self.cli = cli
self.tmpdir = tmpdir
- self.datafiles = datafiles
- if not project_path:
- project_path = str(datafiles)
- else:
- shutil.copytree(str(datafiles), project_path)
-
- self.project_path = project_path
- self.bin_files_path = os.path.join(project_path, "files", "bin-files")
+ self.project_path = str(datafiles)
+ self.bin_files_path = os.path.join(self.project_path, "files", "bin-files")
self.workspace_cmd = os.path.join(self.project_path, "workspace_cmd")
- def create_workspace_element(self, kind, suffix="", workspace_dir=None, element_attrs=None):
- element_name = "workspace-test-{}{}.bst".format(kind, suffix)
+ def create_workspace_element(self, kind):
+ element_name = "workspace-test-{}.bst".format(kind)
element_path = os.path.join(self.project_path, "elements")
- if not workspace_dir:
- workspace_dir = os.path.join(self.workspace_cmd, element_name)
- if workspace_dir[-4:] == ".bst":
- workspace_dir = workspace_dir[:-4]
+ # remove the '.bst' at the end of the element
+ workspace_dir = os.path.join(self.workspace_cmd, element_name[:-4])
# Create our repo object of the given source type with
# the bin files, and then collect the initial ref.
@@ -64,40 +55,33 @@ class WorkspaceCreator:
# Write out our test target
element = {"kind": "import", "sources": [repo.source_config(ref=ref)]}
- if element_attrs:
- element = {**element, **element_attrs}
_yaml.roundtrip_dump(element, os.path.join(element_path, element_name))
# Assert that there is no reference, a fetch is needed
assert self.cli.get_element_state(self.project_path, element_name) == "fetch needed"
return element_name, workspace_dir
- def open_workspace(self, kind, suffix=None, workspace_dir=None, element_attrs=None, no_checkout=False):
+ def open_workspace(self, kind):
- element_name, workspace_dir = self.create_workspace_element(kind, suffix, workspace_dir, element_attrs)
+ element_name, workspace_dir = self.create_workspace_element(kind)
os.makedirs(self.workspace_cmd, exist_ok=True)
# Now open the workspace, this should have the effect of automatically
# fetching the source from the repo.
args = ["workspace", "open"]
-
- if no_checkout:
- args.append("--no-checkout")
- if workspace_dir is not None:
- args.extend(["--directory", workspace_dir])
+ args.extend(["--directory", workspace_dir])
args.append(element_name)
result = self.cli.run(cwd=self.workspace_cmd, project=self.project_path, args=args)
result.assert_success()
- if not no_checkout:
- # Assert that we are now buildable because the source is now cached.
- assert self.cli.get_element_state(self.project_path, element_name) == "buildable"
+ # Assert that we are now buildable because the source is now cached.
+ assert self.cli.get_element_state(self.project_path, element_name) == "buildable"
- # Check that the executable hello file is found in each workspace
- filename = os.path.join(workspace_dir, "usr", "bin", "hello")
- assert os.path.exists(filename)
+ # Check that the executable hello file is found in each workspace
+ filename = os.path.join(workspace_dir, "usr", "bin", "hello")
+ assert os.path.exists(filename)
@pytest.mark.datafiles(DATA_DIR)