Skip to content

Commit

Permalink
main: fix list assembly of suppress
Browse files Browse the repository at this point in the history
when passing `--suppress=a --suppress=b` into
the argparse instance, we would have gotten
weird results.
Fix that and also fully support having multiple
suppression as a space separated list passed
to the parser.
To avoid future regressions a test was added.

Co-authored-by: Angelo Compagnucci [email protected]
Signed-off-by: Konrad Weihmann <[email protected]>
  • Loading branch information
priv-kweihmann committed Oct 12, 2023
1 parent a3c951d commit 2542421
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
8 changes: 4 additions & 4 deletions oelint_adv/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
class TypeSafeAppendAction(argparse.Action):

def __call__(self, parser, namespace, values, option_string=None):
if not isinstance(values, str):
return # pragma: no cover
items = getattr(namespace, self.dest) or []
if isinstance(items, str):
items = RegexRpl.split(r'\s+|\t+|\n+', items) # pragma: no cover
items.append(values) # pragma: no cover
setattr(namespace, self.dest, items) # pragma: no cover
items.extend(RegexRpl.split(r'\s+|\t+|\n+', values.strip('"').strip("'")))
setattr(namespace, self.dest, items)


def deserialize_boolean_options(options: Dict) -> Dict[str, Union[str, bool]]:
Expand Down
19 changes: 19 additions & 0 deletions tests/test_user_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,3 +836,22 @@ def test_sorted_by_file_and_line(self, capsys, input_):
issues = [x[0] for x in run(_args)]

assert sorted(issues, key=lambda x: x[0]) == issues

@pytest.mark.parametrize('input_',
[
{
'oelint_adv-test_2.bb':
'''
VAR = "1"
INSANE_SKIP_${PN} = "foo"
''',
}
],
)
def test_suppress(self, capsys, input_):
_args = self._create_args(input_, ['--suppress="a b c"', '--suppress="d"'])

assert "a" in _args.suppress
assert "b" in _args.suppress
assert "c" in _args.suppress
assert "d" in _args.suppress

0 comments on commit 2542421

Please sign in to comment.