bitbake-devel.lists.openembedded.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] tests: git-lfs: Restore _find_git_lfs
@ 2023-02-17 17:00 Paulo Neves
  2023-02-17 17:00 ` [PATCH 2/5] test: Add real git lfs tests and decorator Paulo Neves
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Paulo Neves @ 2023-02-17 17:00 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Paulo Neves

Not restoring the mocked _find_git_lfs leads to other tests
failing.

Signed-off-by: Paulo Neves <paulo@myneves.com>
---
 lib/bb/tests/fetch.py | 40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index f3890321d..6d16cf59a 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -2250,12 +2250,16 @@ class GitLfsTest(FetcherTest):
             shutil.rmtree(self.gitdir, ignore_errors=True)
             fetcher.unpack(self.d.getVar('WORKDIR'))

-        # If git-lfs cannot be found, the unpack should throw an error
-        with self.assertRaises(bb.fetch2.FetchError):
-            fetcher.download()
-            ud.method._find_git_lfs = lambda d: False
-            shutil.rmtree(self.gitdir, ignore_errors=True)
-            fetcher.unpack(self.d.getVar('WORKDIR'))
+        old_find_git_lfs = ud.method._find_git_lfs
+        try:
+            # If git-lfs cannot be found, the unpack should throw an error
+            with self.assertRaises(bb.fetch2.FetchError):
+                fetcher.download()
+                ud.method._find_git_lfs = lambda d: False
+                shutil.rmtree(self.gitdir, ignore_errors=True)
+                fetcher.unpack(self.d.getVar('WORKDIR'))
+        finally:
+            ud.method._find_git_lfs = old_find_git_lfs

     def test_lfs_disabled(self):
         import shutil
@@ -2270,17 +2274,21 @@ class GitLfsTest(FetcherTest):
         fetcher, ud = self.fetch()
         self.assertIsNotNone(ud.method._find_git_lfs)

-        # If git-lfs can be found, the unpack should be successful. A
-        # live copy of git-lfs is not required for this case, so
-        # unconditionally forge its presence.
-        ud.method._find_git_lfs = lambda d: True
-        shutil.rmtree(self.gitdir, ignore_errors=True)
-        fetcher.unpack(self.d.getVar('WORKDIR'))
+        old_find_git_lfs = ud.method._find_git_lfs
+        try:
+            # If git-lfs can be found, the unpack should be successful. A
+            # live copy of git-lfs is not required for this case, so
+            # unconditionally forge its presence.
+            ud.method._find_git_lfs = lambda d: True
+            shutil.rmtree(self.gitdir, ignore_errors=True)
+            fetcher.unpack(self.d.getVar('WORKDIR'))
+            # If git-lfs cannot be found, the unpack should be successful

-        # If git-lfs cannot be found, the unpack should be successful
-        ud.method._find_git_lfs = lambda d: False
-        shutil.rmtree(self.gitdir, ignore_errors=True)
-        fetcher.unpack(self.d.getVar('WORKDIR'))
+            ud.method._find_git_lfs = lambda d: False
+            shutil.rmtree(self.gitdir, ignore_errors=True)
+            fetcher.unpack(self.d.getVar('WORKDIR'))
+        finally:
+            ud.method._find_git_lfs = old_find_git_lfs

 class GitURLWithSpacesTest(FetcherTest):
     test_git_urls = {
--
2.34.1




^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-02-22 12:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-17 17:00 [PATCH 1/5] tests: git-lfs: Restore _find_git_lfs Paulo Neves
2023-02-17 17:00 ` [PATCH 2/5] test: Add real git lfs tests and decorator Paulo Neves
2023-02-17 17:00 ` [PATCH 3/5] git: Remove is None check on _find_git_lfs Paulo Neves
2023-02-22 12:03   ` [bitbake-devel] " Richard Purdie
2023-02-17 17:01 ` [PATCH 4/5] git.py: @_contains_lfs: Removed unused variables Paulo Neves
2023-02-17 17:01 ` [PATCH 5/5] git.py Replace mkdtemp with TemporaryDirectory and avoid exception masking Paulo Neves
2023-02-22 12:01 ` [bitbake-devel] [PATCH 1/5] tests: git-lfs: Restore _find_git_lfs Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).