]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
patchtest: tests: test_metadata.py: simplify SRC_URI collection, remove unneeded...
authorTrevor Gamblin <tgamblin@baylibre.com>
Thu, 2 Jul 2026 15:22:10 +0000 (11:22 -0400)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 6 Jul 2026 16:15:09 +0000 (17:15 +0100)
The pretest_src_uri_left_files() and test_src_uri_left_files() functions
both use the same logic to check for changes, so encapsulate that into a
function for easier re-use. Also remove a pyparsing import which isn't
needed, since it already gets pulled in through other patchtest modules.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/patchtest/tests/test_metadata.py

index 30da8dbe604acb53d283d63f43316c169ddc7f15..442e80973db977931c71b5725a47b75a56d725c3 100644 (file)
@@ -8,7 +8,6 @@ import base
 import collections
 import os
 import patchtest_patterns
-import pyparsing
 from patchtest_parser import PatchtestParser
 
 # Data store commonly used to share values between pre and post-merge tests
@@ -108,39 +107,28 @@ class TestMetadata(base.Metadata):
                             ],
                         )
 
-    def pretest_src_uri_left_files(self):
-        # these tests just make sense on patches that can be merged
-        if not PatchtestParser.repo.canbemerged():
-            self.skip("Patch cannot be merged")
-        if not self.modified:
-            self.skip('No modified recipes, skipping pretest')
-
-        # get the proper metadata values
+    def _collect_src_uri(self, key_prefix):
         for pn in self.modified:
-            # we are not interested in images
             if 'core-image' in pn:
                 continue
             rd = self.tinfoil.parse_recipe(pn)
             PatchTestDataStore[
-                "%s-%s-%s" % (self.shortid(), patchtest_patterns.metadata_src_uri, pn)
+                "%s-%s-%s" % (key_prefix, patchtest_patterns.metadata_src_uri, pn)
             ] = rd.getVar(patchtest_patterns.metadata_src_uri)
 
-    def test_src_uri_left_files(self):
-        # these tests just make sense on patches that can be merged
+    def pretest_src_uri_left_files(self):
         if not PatchtestParser.repo.canbemerged():
             self.skip("Patch cannot be merged")
         if not self.modified:
             self.skip('No modified recipes, skipping pretest')
+        self._collect_src_uri(self.shortid())
 
-        # get the proper metadata values
-        for pn in self.modified:
-            # we are not interested in images
-            if 'core-image' in pn:
-                continue
-            rd = self.tinfoil.parse_recipe(pn)
-            PatchTestDataStore[
-                "%s-%s-%s" % (self.shortid(), patchtest_patterns.metadata_src_uri, pn)
-            ] = rd.getVar(patchtest_patterns.metadata_src_uri)
+    def test_src_uri_left_files(self):
+        if not PatchtestParser.repo.canbemerged():
+            self.skip("Patch cannot be merged")
+        if not self.modified:
+            self.skip('No modified recipes, skipping test')
+        self._collect_src_uri(self.shortid())
 
         for pn in self.modified:
             pretest_src_uri = PatchTestDataStore[