diff --git a/oelint_adv/core.py b/oelint_adv/core.py index f1b4d8d0..5004a96a 100644 --- a/oelint_adv/core.py +++ b/oelint_adv/core.py @@ -30,6 +30,8 @@ def __call__(self, parser, namespace, values, option_string=None) -> None: if not isinstance(values, str): return # pragma: no cover items = getattr(namespace, self.dest) or [] + if not isinstance(items, list): + items = [x.strip() for x in items.split() if x.strip()] items.extend(RegexRpl.split(r'\s+|\t+|\n+', values.strip('"').strip("'"))) setattr(namespace, self.dest, items) diff --git a/tests/test_configfile.py b/tests/test_configfile.py index e038c3af..d0526852 100644 --- a/tests/test_configfile.py +++ b/tests/test_configfile.py @@ -269,3 +269,82 @@ def test_option_deserialization(self): options = {'a': 'True', 'b': True, 'c': 'False', 'd': False, 'e': 'other value'} deserialized = deserialize_boolean_options(options) assert deserialized == {'a': True, 'b': True, 'c': False, 'd': False, 'e': 'other value'} + + @pytest.mark.parametrize('input_', + [ + { + 'oelint adv-test.bb': + ''' + VAR:append:prepend = "1" + ''', + }, + ], + ) + def test_config_file_suppress(self, input_): + _cstfile = self._create_tempfile( + '.oelint.cfg', + ''' + [oelint] + suppress= + oelint.vars.doublemodify + oelint.var.suggestedvar.BUGTRACKER + ''') + os.environ['OELINT_CONFIG'] = _cstfile + _args = self._create_args(input_) + self.check_for_id(_args, 'oelint.vars.doublemodify', 0) + self.check_for_id(_args, 'oelint.var.suggestedvar.BUGTRACKER', 0) + self.check_for_id(_args, 'oelint.var.mandatoryvar.LICENSE', 1) + + @pytest.mark.parametrize('input_', + [ + { + 'oelint adv-test.bb': + ''' + VAR:append:prepend = "1" + ''', + }, + ], + ) + def test_config_file_suppress_merge_with_cli(self, input_): + _cstfile = self._create_tempfile( + '.oelint.cfg', + ''' + [oelint] + suppress= + oelint.vars.doublemodify + oelint.var.suggestedvar.BUGTRACKER + ''') + os.environ['OELINT_CONFIG'] = _cstfile + _args = self._create_args(input_, ['--suppress', 'oelint.var.mandatoryvar.LICENSE']) + self.check_for_id(_args, 'oelint.vars.doublemodify', 0) + self.check_for_id(_args, 'oelint.var.suggestedvar.BUGTRACKER', 0) + self.check_for_id(_args, 'oelint.var.mandatoryvar.LICENSE', 0) + self.check_for_id(_args, 'oelint.var.mandatoryvar.HOMEPAGE', 1) + + @pytest.mark.parametrize('input_', + [ + { + 'oelint adv-test.bb': + ''' + VAR:append:prepend = "1" + ''', + }, + ], + ) + def test_config_file_suppress_merge_with_cli_multiple(self, input_): + _cstfile = self._create_tempfile( + '.oelint.cfg', + ''' + [oelint] + suppress= + oelint.vars.doublemodify + oelint.var.suggestedvar.BUGTRACKER + ''') + os.environ['OELINT_CONFIG'] = _cstfile + _args = self._create_args(input_, + ['--suppress', 'oelint.var.mandatoryvar.LICENSE', + '--suppress', 'oelint.var.mandatoryvar.HOMEPAGE']) + self.check_for_id(_args, 'oelint.vars.doublemodify', 0) + self.check_for_id(_args, 'oelint.var.suggestedvar.BUGTRACKER', 0) + self.check_for_id(_args, 'oelint.var.mandatoryvar.LICENSE', 0) + self.check_for_id(_args, 'oelint.var.mandatoryvar.HOMEPAGE', 0)