Skip to content

Commit

Permalink
stash: fix GetLoneAppends
Browse files Browse the repository at this point in the history
if a bbappend would have contained a require or
include statement, the links of the include file
would have been computed the same as a bb file,
thus preventing to identify the bbappend as a
scanable file, if it would have been passed alone
into the stash parsing.

Fix that by limiting the "linked appends" to bb files only.

Closes #150

Signed-off-by: Konrad Weihmann <[email protected]>
  • Loading branch information
priv-kweihmann committed Dec 30, 2023
1 parent a7932d7 commit 57e8e8d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion oelint_parser/cls_stash.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def GetLoneAppends(self):
for x in self.__list:
if x.Origin.endswith(".bbappend"):
__appends.append(x.Origin)
else:
elif x.Origin.endswith(".bb"):
__linked_appends += x.Links
return sorted({x for x in __appends if x not in __linked_appends})

Expand Down
42 changes: 42 additions & 0 deletions tests/test_bbappends.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from logging import log
import unittest
import os
import sys


class OelintBBAppendsTest(unittest.TestCase):

RECIPE = os.path.join(os.path.dirname(__file__), "testlayer/recipes-appends/test.bb")
RECIPE_APPEND = os.path.join(os.path.dirname(__file__), "testlayer/recipes-appends/test.bbappend")

def setUp(self):
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__) + "/../"))

def test_recipe(self):
from oelint_parser.cls_stash import Stash
self.__stash = Stash()
self.__stash.AddFile(OelintBBAppendsTest.RECIPE)
self.__stash.Finalize()
self.assertEqual(len(self.__stash.GetLoneAppends()), 0, msg="No lone appends")
self.assertEqual(len(self.__stash.GetRecipes()), 1, msg="One recipe")

def test_bbappend(self):
from oelint_parser.cls_stash import Stash
self.__stash = Stash()
self.__stash.AddFile(OelintBBAppendsTest.RECIPE_APPEND)
self.__stash.Finalize()
self.assertEqual(len(self.__stash.GetLoneAppends()), 1, msg="One lone appends")
self.assertEqual(len(self.__stash.GetRecipes()), 0, msg="No recipe")

def test_bbappend_and_recipe(self):
from oelint_parser.cls_stash import Stash
self.__stash = Stash()
self.__stash.AddFile(OelintBBAppendsTest.RECIPE)
self.__stash.AddFile(OelintBBAppendsTest.RECIPE_APPEND)
self.__stash.Finalize()
self.assertEqual(len(self.__stash.GetLoneAppends()), 0, msg="No lone appends")
self.assertEqual(len(self.__stash.GetRecipes()), 1, msg="One recipe")


if __name__ == "__main__":
unittest.main()
3 changes: 3 additions & 0 deletions tests/testlayer/recipes-appends/test.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require test.inc

B = "1"
3 changes: 3 additions & 0 deletions tests/testlayer/recipes-appends/test.bbappend
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require test.inc

C = "3"
1 change: 1 addition & 0 deletions tests/testlayer/recipes-appends/test.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A = "1"

0 comments on commit 57e8e8d

Please sign in to comment.