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 16:17:35 UTC

[buildstream] branch bschubert/rewrite-workspace-multi-test created (now 667fe33)

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

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


      at 667fe33  workspace.py: Remove assumption on specific kinds to testing multiple

This branch includes the following new commits:

     new 667fe33  workspace.py: Remove assumption on specific kinds to testing multiple

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: Remove assumption on specific kinds to testing multiple

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

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

commit 667fe33482bb0c646a80aacc13d1315c9acad355
Author: Benjamin Schubert <co...@benschubert.me>
AuthorDate: Sat Jan 15 15:56:21 2022 +0000

    workspace.py: Remove assumption on specific kinds to testing multiple
    
    This makes the test more explicit in testing that it can actually open
    multiple different projects at the same time, and removes the need of
    actually using multiple kinds
---
 tests/frontend/workspace.py | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py
index 66e195c..1a7c879 100644
--- a/tests/frontend/workspace.py
+++ b/tests/frontend/workspace.py
@@ -30,6 +30,7 @@ import os
 import stat
 import shutil
 import subprocess
+import tempfile
 
 import pytest
 
@@ -74,8 +75,19 @@ class WorkspaceCreator:
 
         # Create our repo object of the given source type with
         # the bin files, and then collect the initial ref.
-        repo = create_repo(kind, str(self.tmpdir))
-        ref = repo.create(self.bin_files_path)
+        # And ensure we store it in a suffix-specific directory, to avoid clashes
+        # if using multiple times the same kind element here.
+        repo = create_repo(kind, str(self.tmpdir), "repo-for-{}".format(element_name))
+
+        with tempfile.TemporaryDirectory() as tempdir:
+            dst_repo = os.path.join(tempdir, "repo")
+            shutil.copytree(self.bin_files_path, dst_repo)
+            # Touch a file with the element name in, to allow validating that this
+            # is the correct repo
+            # pylint: disable=consider-using-with
+            open(os.path.join(dst_repo, element_name), "a", encoding="utf-8").close()
+
+            ref = repo.create(os.path.join(tempdir, "repo"))
 
         # Write out our test target
         element = {"kind": "import", "sources": [repo.source_config(ref=ref)]}
@@ -175,20 +187,13 @@ def test_open_bzr_customize(cli, tmpdir, datafiles):
 
 @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)
 
     for (elname, workspace), kind in zip(workspaces, repo_kinds):
         assert kind in elname
         workspace_lsdir = os.listdir(workspace)
-        if kind == "git":
-            assert ".git" in workspace_lsdir
-        elif kind == "bzr":
-            assert ".bzr" in workspace_lsdir
-        else:
-            assert ".git" not in workspace_lsdir
-            assert ".bzr" not in workspace_lsdir
+        assert elname in workspace_lsdir
 
 
 @pytest.mark.skipif(os.geteuid() == 0, reason="root may have CAP_DAC_OVERRIDE and ignore permissions")