diff mbox series

[bitbake-devel,V2,2/2] lib/bb/tests/fetch.py: add test case to ensure no FetchData attribute error

Message ID 20260228082439.3613864-2-Qi.Chen@windriver.com
State New
Headers show
Series [bitbake-devel,V2,1/2] fetch2/git.py: fix update_mirror_links | expand

Commit Message

Chen, Qi Feb. 28, 2026, 8:24 a.m. UTC
From: Chen Qi <Qi.Chen@windriver.com>

When using git:// -> file:// in PREMIRRORS and we have the same url
in SRC_URI twice, we reveal the following error:

  AttributeError: 'FetchData' object has no attribute 'shallow'

Add a test case to ensure future changes don't introduce the error
back.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 lib/bb/tests/fetch.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 2a8501dc2..74eb73472 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -2089,6 +2089,29 @@  class GitShallowTest(FetcherTest):
         self.fetch_and_unpack()
         self.assertRevCount(1)
 
+    @skipIfNoNetwork()
+    def test_shallow_mirrors_with_multiple_same_urls(self):
+        url = "git://git.openembedded.org/bitbake;branch=master;protocol=https;rev=82ea737a0b42a8b53e11c9cde141e9e9c0bd8c40"
+
+        d = self.d.createCopy()
+        d.delVar('AUTOREV')
+        d.delVar('SRCREV')
+
+        # prepare premirror
+        premirror = os.path.join(self.tempdir, "premirror")
+        os.mkdir(premirror)
+        d.setVar("DL_DIR", premirror)
+        fetcher = bb.fetch.Fetch([url], d)
+        fetcher.download()
+
+        # set PREMIRRORS
+        d.setVar('PREMIRRORS', 'git://.*/.* file://%s/' % premirror)
+
+        # set DL_DIR back and use the same url multiple times to fetch
+        d.setVar("DL_DIR", self.dldir)
+        fetcher2 = bb.fetch.Fetch([url, url], d)
+        fetcher2.download()
+
     def test_shallow_invalid_depth(self):
         self.add_empty_file('a')
         self.add_empty_file('b')