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

tvb pushed a commit to branch tristan/remove-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 9d0dce42318da4d687ff60e38851d4cd47614527
Author: Tristan van Berkom <[email protected]>
AuthorDate: Wed Mar 30 14:02:22 2022 +0900

    tests/testutils/element_generators.py: Port create_element_size() to use 
tar repo
    
    Also remove unused update_element_size() utility function (which cannot be
    implemented with a tar repo anyway, luckily this is unused).
---
 tests/sourcecache/source-checkout.py  |  6 ++---
 tests/sourcecache/staging.py          |  4 ++--
 tests/sourcecache/workspace.py        |  6 ++---
 tests/testutils/__init__.py           |  2 +-
 tests/testutils/element_generators.py | 41 +++--------------------------------
 5 files changed, 12 insertions(+), 47 deletions(-)

diff --git a/tests/sourcecache/source-checkout.py 
b/tests/sourcecache/source-checkout.py
index c87eaff..70a074d 100644
--- a/tests/sourcecache/source-checkout.py
+++ b/tests/sourcecache/source-checkout.py
@@ -52,7 +52,7 @@ def test_source_checkout(tmpdir, datafiles, cli):
     # check implicit fetching
     res = cli.run(project=project_dir, args=["source", "checkout", 
"--directory", target_dir, "target.bst"])
     res.assert_success()
-    assert "Fetching from" in res.stderr
+    assert "Fetching" in res.stderr
 
     # remove the directory and check source checkout works with sources only in
     # the CAS
@@ -62,11 +62,11 @@ def test_source_checkout(tmpdir, datafiles, cli):
 
     res = cli.run(project=project_dir, args=["source", "checkout", 
"--directory", target_dir, "target.bst"])
     res.assert_success()
-    assert "Fetching from" not in res.stderr
+    assert "Fetching" not in res.stderr
 
     # remove the CAS and check it doesn't work again
     shutil.rmtree(target_dir)
     shutil.rmtree(os.path.join(cache_dir, "cas"))
 
     res = cli.run(project=project_dir, args=["source", "checkout", 
"--directory", target_dir, "target.bst"])
-    res.assert_task_error(ErrorDomain.PLUGIN, None)
+    res.assert_task_error(ErrorDomain.SOURCE, None)
diff --git a/tests/sourcecache/staging.py b/tests/sourcecache/staging.py
index 09ff608..61c0feb 100644
--- a/tests/sourcecache/staging.py
+++ b/tests/sourcecache/staging.py
@@ -153,7 +153,7 @@ def test_staged_source_build(tmpdir, datafiles, cli):
     # build and check that no fetching was done.
     res = cli.run(project=project_dir, args=["build", "target.bst"])
     res.assert_success()
-    assert "Fetching from" not in res.stderr
+    assert "Fetching" not in res.stderr
 
     # assert the source directory is still empty (though there may be
     # directories from staging etc.)
@@ -172,4 +172,4 @@ def test_staged_source_build(tmpdir, datafiles, cli):
     # Check that it now fetches from when building the target
     res = cli.run(project=project_dir, args=["build", "target.bst"])
     res.assert_success()
-    assert "Fetching from" in res.stderr
+    assert "Fetching" in res.stderr
diff --git a/tests/sourcecache/workspace.py b/tests/sourcecache/workspace.py
index 00419c1..13eb18e 100644
--- a/tests/sourcecache/workspace.py
+++ b/tests/sourcecache/workspace.py
@@ -48,7 +48,7 @@ def test_workspace_source_fetch(tmpdir, datafiles, cli):
     create_element_size("target.bst", project_dir, element_path, [], 10000)
     res = cli.run(project=project_dir, args=["build", "target.bst"])
     res.assert_success()
-    assert "Fetching from" in res.stderr
+    assert "Fetching" in res.stderr
 
     # remove the original sources
     shutil.rmtree(source_dir)
@@ -56,7 +56,7 @@ def test_workspace_source_fetch(tmpdir, datafiles, cli):
     # Open a workspace and check that fetches the original sources
     res = cli.run(project=project_dir, args=["workspace", "open", 
"target.bst", "--directory", workspace])
     res.assert_success()
-    assert "Fetching from" in res.stderr
+    assert "Fetching" in res.stderr
 
     assert os.listdir(workspace) != []
 
@@ -89,7 +89,7 @@ def test_workspace_open_no_source_push(tmpdir, datafiles, 
cli):
         create_element_size("target.bst", project_dir, element_path, [], 10000)
         res = cli.run(project=project_dir, args=["build", "target.bst"])
         res.assert_success()
-        assert "Fetching from" in res.stderr
+        assert "Fetching" in res.stderr
         assert "Pushed source" in res.stderr
 
         # clear the cas and open a workspace
diff --git a/tests/testutils/__init__.py b/tests/testutils/__init__.py
index 0fe23dc..87f61d9 100644
--- a/tests/testutils/__init__.py
+++ b/tests/testutils/__init__.py
@@ -24,7 +24,7 @@
 
 from .artifactshare import create_artifact_share, create_split_share, 
assert_shared, assert_not_shared, ArtifactShare
 from .context import dummy_context
-from .element_generators import create_element_size, update_element_size
+from .element_generators import create_element_size
 from .junction import generate_junction
 from .runner_integration import wait_for_cache_granularity
 from .python_repo import setup_pypi_repo
diff --git a/tests/testutils/element_generators.py 
b/tests/testutils/element_generators.py
index 5c6fa5d..fa1f9c0 100644
--- a/tests/testutils/element_generators.py
+++ b/tests/testutils/element_generators.py
@@ -20,16 +20,15 @@ from buildstream._testing import create_repo
 #    size: (int) size of the element in bytes
 #
 # Returns:
-#    (Repo): A git repo which can be used to introduce trackable changes
-#            by using the update_element_size() function below.
+#    (Repo): A repo representing the sized element
 #
 def create_element_size(name, project_dir, elements_path, dependencies, size):
     full_elements_path = os.path.join(project_dir, elements_path)
     os.makedirs(full_elements_path, exist_ok=True)
 
-    # Create a git repo
+    # Create a repo
     repodir = os.path.join(project_dir, "repos")
-    repo = create_repo("git", repodir, subdir=name)
+    repo = create_repo("tar", repodir, subdir=name)
 
     with utils._tempdir(dir=project_dir) as tmp:
 
@@ -61,37 +60,3 @@ def create_element_size(name, project_dir, elements_path, 
dependencies, size):
 
     # Return the repo, so that it can later be used to add commits
     return repo
-
-
-# update_element_size()
-#
-# Updates a repo returned by create_element_size() such that
-# the newly added commit is completely changed, and has the newly
-# specified size.
-#
-# The name and project_dir arguments must match the arguments
-# previously given to create_element_size()
-#
-# Args:
-#    name: (str) of the element name (e.g. target.bst)
-#    project_dir (str): The path to the project
-#    repo: (Repo) The Repo returned by create_element_size()
-#    size: (int) The new size which the element generates, in bytes
-#
-# Returns:
-#    (Repo): A git repo which can be used to introduce trackable changes
-#            by using the update_element_size() function below.
-#
-def update_element_size(name, project_dir, repo, size):
-
-    with utils._tempdir(dir=project_dir) as tmp:
-
-        new_file = os.path.join(tmp, name)
-
-        # Use /dev/urandom to create the sized file in the datadir
-        with open(new_file, "wb+") as f:
-            f.write(os.urandom(size))
-
-        # Modify the git repo with a new commit to the same path,
-        # replacing the original file with a new one.
-        repo.modify_file(new_file, os.path.join("data", name))

Reply via email to