Skip to content

Commit

Permalink
parser: fix inherit parsing
Browse files Browse the repository at this point in the history
and ignore any kind of inline inherit, which could be part of a string or function

Closes #143

Signed-off-by: Konrad Weihmann <[email protected]>
  • Loading branch information
priv-kweihmann committed Dec 23, 2023
1 parent 04f14b1 commit d668b63
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion oelint_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def get_items(stash, _file, lineOffset=0):
res = []
__regex_var = r"^(?P<varname>([A-Z0-9a-z_.-]|\$|\{|\}|:)+?)(\[(?P<ident>(\w|-|\.)+)\])*(?P<varop>(\s|\t)*(\+|\?|\:|\.)*=(\+|\.)*(\s|\t)*)(?P<varval>.*)"
__regex_func = r"^((?P<py>python)\s*|(?P<fr>fakeroot\s*))*(?P<func>[\w\.\-\+\{\}:\$]+)?\s*\(\s*\)\s*\{(?P<funcbody>.*)\s*\}"
__regex_inherit = r"^.*?inherit(\s+|\t+)(?P<inhname>.+)"
__regex_inherit = r"^(\s|\t)*inherit(\s+|\t+)(?P<inhname>.+)"
__regex_export_wval = r"^\s*?export(\s+|\t+)(?P<name>.+)\s*=\s*\"(?P<value>.*)\""
__regex_export_woval = r"^\s*?export(\s+|\t+)(?P<name>.+)\s*$"
__regex_comments = r"^(\s|\t)*#+\s*(?P<body>.*)"
Expand Down
2 changes: 2 additions & 0 deletions tests/test-recipe_1.0.bb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ require another_file.inc

inherit someclass

A[doc] = "This string is not an inherit statement."

do_configure[noexec] = "1"

export lib = "${bindir}/foo"
Expand Down
15 changes: 15 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,21 @@ def test_append_to_stash(self):

assert len(_stash) == 3

def test_inherit(self):
from oelint_parser.cls_item import Variable
from oelint_parser.helper_files import expand_term
from oelint_parser.cls_stash import Stash

self.__stash = Stash()
self.__stash.AddFile(OelintParserTest.RECIPE)

_stash = self.__stash.GetItemsFor(classifier=Variable.CLASSIFIER,
attribute=Variable.ATTR_VAR,
attributeValue="inherit")
self.assertTrue(_stash, msg="Stash has no items")
self.assertEqual(len(_stash), 1, msg="Only one item is found")
for x in _stash:
self.assertEqual(x.VarValue, 'someclass')

if __name__ == "__main__":
unittest.main()

0 comments on commit d668b63

Please sign in to comment.