You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by be...@apache.org on 2022/01/15 13:53:22 UTC

[buildstream] branch bschubert/move-test created (now 9e4a2db)

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

benschubert pushed a change to branch bschubert/move-test
in repository https://gitbox.apache.org/repos/asf/buildstream.git.


      at 9e4a2db  workspace.py: Move bzr specific test to the bzr source

This branch includes the following new commits:

     new 9e4a2db  workspace.py: Move bzr specific test to the bzr source

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[buildstream] 01/01: workspace.py: Move bzr specific test to the bzr source

Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

benschubert pushed a commit to branch bschubert/move-test
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 9e4a2db5a49f58ecd1b5c1a0387962b2a3e54578
Author: Benjamin Schubert <co...@benschubert.me>
AuthorDate: Sat Jan 15 13:50:47 2022 +0000

    workspace.py: Move bzr specific test to the bzr source
---
 tests/frontend/workspace.py | 17 -----------------
 tests/sources/bzr.py        | 30 +++++++++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py
index 66e195c..6b33f35 100644
--- a/tests/frontend/workspace.py
+++ b/tests/frontend/workspace.py
@@ -157,23 +157,6 @@ def open_workspace(
 
 
 @pytest.mark.datafiles(DATA_DIR)
-def test_open_bzr_customize(cli, tmpdir, datafiles):
-    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "bzr")
-
-    # Check that the .bzr dir exists
-    bzrdir = os.path.join(workspace, ".bzr")
-    assert os.path.isdir(bzrdir)
-
-    # Check that the correct origin branch is set
-    element_config = _yaml.load(os.path.join(project, "elements", element_name), shortname=None)
-    source_config = element_config.get_sequence("sources").mapping_at(0)
-    output = subprocess.check_output(["bzr", "info"], cwd=workspace)
-    stripped_url = source_config.get_str("url").lstrip("file:///")
-    expected_output_str = "checkout of branch: /{}/{}".format(stripped_url, source_config.get_str("track"))
-    assert expected_output_str in str(output)
-
-
-@pytest.mark.datafiles(DATA_DIR)
 def test_open_multi(cli, tmpdir, datafiles):
 
     workspace_object = WorkspaceCreator(cli, tmpdir, datafiles)
diff --git a/tests/sources/bzr.py b/tests/sources/bzr.py
index f0dad8f..3ba4229 100644
--- a/tests/sources/bzr.py
+++ b/tests/sources/bzr.py
@@ -2,17 +2,20 @@
 # pylint: disable=redefined-outer-name
 
 import os
+import subprocess
+
 import pytest
 
+from buildstream import _yaml
 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
 
+pytestmark = pytest.mark.skipif(HAVE_BZR is False, reason="bzr is not available")
 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "bzr")
 
 
-@pytest.mark.skipif(HAVE_BZR is False, reason="bzr is not available")
 @pytest.mark.datafiles(os.path.join(DATA_DIR))
 def test_fetch_checkout(cli, tmpdir, datafiles):
     project = str(datafiles)
@@ -38,3 +41,28 @@ def test_fetch_checkout(cli, tmpdir, datafiles):
         text = f.read()
 
     assert text == "test\n"
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_open_bzr_customize(cli, tmpdir, datafiles):
+    project = str(datafiles)
+    repo = create_repo("bzr", str(tmpdir))
+    ref = repo.create(os.path.join(project, "basic"))
+
+    element = {"kind": "import", "sources": [repo.source_config(ref=ref)]}
+    generate_element(project, "target.bst", element)
+
+    workspace = os.path.join(datafiles, "bzr-workspace")
+    result = cli.run(cwd=project, project=project, args=["workspace", "open", "--directory", workspace, "target.bst"])
+    result.assert_success()
+
+    # Check that the .bzr dir exists
+    assert os.path.isdir(os.path.join(workspace, ".bzr"))
+
+    # Check that the correct origin branch is set
+    element_config = _yaml.load(os.path.join(project, "target.bst"), shortname=None)
+    source_config = element_config.get_sequence("sources").mapping_at(0)
+    output = subprocess.check_output(["bzr", "info"], cwd=workspace)
+    stripped_url = source_config.get_str("url").lstrip("file:///")
+    expected_output_str = "checkout of branch: /{}/{}".format(stripped_url, source_config.get_str("track"))
+    assert expected_output_str in str(output)