From 18a4bbb6eca34d1aca5f0398c6756108e2d0fc1f Mon Sep 17 00:00:00 2001 From: Konrad Weihmann Date: Sun, 13 Oct 2024 07:55:02 +0000 Subject: [PATCH] srcurioptions: update database - crate supports downloadfilename - crcc proto -> protocol - add gomod - add gomodgit Signed-off-by: Konrad Weihmann --- oelint_adv/rule_base/rule_var_src_uri.py | 24 ++++++- tests/test_class_oelint_vars_srcurioptions.py | 63 ++++++++++++++++++- tests/test_class_oelint_vars_srcurireqopt.py | 18 +++++- 3 files changed, 99 insertions(+), 6 deletions(-) diff --git a/oelint_adv/rule_base/rule_var_src_uri.py b/oelint_adv/rule_base/rule_var_src_uri.py index 25cad4cd..7e84e145 100644 --- a/oelint_adv/rule_base/rule_var_src_uri.py +++ b/oelint_adv/rule_base/rule_var_src_uri.py @@ -28,10 +28,12 @@ def __init__(self) -> None: 'protocol', 'scmdata', ], - 'crate': [], + 'crate': [ + 'downloadfilename', + ], 'crcc': [ 'module', - 'proto', + 'protocol', 'vob', ], 'cvs': [ @@ -88,6 +90,22 @@ def __init__(self) -> None: 'destdir', 'proto', ], + 'gomod': [ + 'downloadfilename', + 'mod', + 'module', + 'version', + ], + 'gomodgit': [ + 'bareclone', + 'branch', + 'module', + 'nobranch', + 'protocol', + 'repo', + 'srcrev', + 'version', + ], 'hg': [ 'module', 'rev', @@ -148,6 +166,8 @@ def __init__(self) -> None: self._required_might_options = { 'git': ['protocol'], 'gitsm': ['protocol'], + 'gomod': ['version'], + 'gomodgit': ['version'], } self._required_unless_options = { diff --git a/tests/test_class_oelint_vars_srcurioptions.py b/tests/test_class_oelint_vars_srcurioptions.py index 9f82f0cb..d2608e21 100644 --- a/tests/test_class_oelint_vars_srcurioptions.py +++ b/tests/test_class_oelint_vars_srcurioptions.py @@ -65,6 +65,7 @@ 'crate': [ 'apply', 'destsuffix', + 'downloadfilename', 'name', 'patchdir', 'striplevel', @@ -77,7 +78,7 @@ 'module', 'name', 'patchdir', - 'proto', + 'protocol', 'striplevel', 'subdir', 'unpack', @@ -176,6 +177,22 @@ 'name', 'proto', ], + 'gomod': [ + 'downloadfilename', + 'mod', + 'module', + 'version', + ], + 'gomodgit': [ + 'bareclone', + 'branch', + 'module', + 'nobranch', + 'protocol', + 'repo', + 'srcrev', + 'version', + ], 'hg': [ 'apply', 'destsuffix', @@ -372,7 +389,7 @@ def test_good_bzr(self, id_, occurrence, protocol, option): @pytest.mark.parametrize('id_', ['oelint.vars.srcurioptions']) @pytest.mark.parametrize('occurrence', [1]) @pytest.mark.parametrize('protocol', ['crate']) - @pytest.mark.parametrize('option', [x for x in OPTIONS_AVAILABLE if x not in OPTION_MAPPING['az']]) + @pytest.mark.parametrize('option', [x for x in OPTIONS_AVAILABLE if x not in OPTION_MAPPING['crate']]) def test_bad_crate(self, id_, occurrence, protocol, option): input_ = { 'oelint_adv_test.bb': self.__generate_sample_code(protocol, option), @@ -382,7 +399,7 @@ def test_bad_crate(self, id_, occurrence, protocol, option): @pytest.mark.parametrize('id_', ['oelint.vars.srcurioptions']) @pytest.mark.parametrize('occurrence', [0]) @pytest.mark.parametrize('protocol', ['crate']) - @pytest.mark.parametrize('option', OPTION_MAPPING['az']) + @pytest.mark.parametrize('option', OPTION_MAPPING['crate']) def test_good_crate(self, id_, occurrence, protocol, option): input_ = { 'oelint_adv_test.bb': self.__generate_sample_code(protocol, option), @@ -545,6 +562,46 @@ def test_good_gitannex(self, id_, occurrence, protocol, option): } self.check_for_id(self._create_args(input_), id_, occurrence) + @pytest.mark.parametrize('id_', ['oelint.vars.srcurioptions']) + @pytest.mark.parametrize('occurrence', [1]) + @pytest.mark.parametrize('protocol', ['gomod']) + @pytest.mark.parametrize('option', ['xyz', 'abc']) + def test_bad_gomod(self, id_, occurrence, protocol, option): + input_ = { + 'oelint_adv_test.bb': self.__generate_sample_code(protocol, 'version=1;' + option), + } + self.check_for_id(self._create_args(input_), id_, occurrence) + + @pytest.mark.parametrize('id_', ['oelint.vars.srcurioptions']) + @pytest.mark.parametrize('occurrence', [0]) + @pytest.mark.parametrize('protocol', ['gomod']) + @pytest.mark.parametrize('option', OPTION_MAPPING['gomod']) + def test_good_gomod(self, id_, occurrence, protocol, option): + input_ = { + 'oelint_adv_test.bb': self.__generate_sample_code(protocol, 'version=1;' + option), + } + self.check_for_id(self._create_args(input_), id_, occurrence) + + @pytest.mark.parametrize('id_', ['oelint.vars.srcurioptions']) + @pytest.mark.parametrize('occurrence', [1]) + @pytest.mark.parametrize('protocol', ['gomodgit']) + @pytest.mark.parametrize('option', ['xyz', 'abc']) + def test_bad_gomodgit(self, id_, occurrence, protocol, option): + input_ = { + 'oelint_adv_test.bb': self.__generate_sample_code(protocol, 'version=1;' + option), + } + self.check_for_id(self._create_args(input_), id_, occurrence) + + @pytest.mark.parametrize('id_', ['oelint.vars.srcurioptions']) + @pytest.mark.parametrize('occurrence', [0]) + @pytest.mark.parametrize('protocol', ['gomodgit']) + @pytest.mark.parametrize('option', OPTION_MAPPING['gomodgit']) + def test_good_gomodgit(self, id_, occurrence, protocol, option): + input_ = { + 'oelint_adv_test.bb': self.__generate_sample_code(protocol, 'version=1;' + option), + } + self.check_for_id(self._create_args(input_), id_, occurrence) + @pytest.mark.parametrize('id_', ['oelint.vars.srcurioptions']) @pytest.mark.parametrize('occurrence', [1]) @pytest.mark.parametrize('protocol', ['hg']) diff --git a/tests/test_class_oelint_vars_srcurireqopt.py b/tests/test_class_oelint_vars_srcurireqopt.py index 3e9f7670..49aff81d 100644 --- a/tests/test_class_oelint_vars_srcurireqopt.py +++ b/tests/test_class_oelint_vars_srcurireqopt.py @@ -25,7 +25,7 @@ class TestClassOelintVarsSRCURIReqOpt(TestBaseClass): 'oelint_adv_test.bb': 'SRC_URI += "gitsm://foo.org/gaz.git;name=foo;protocol=ssh"', }, - { + { 'oelint_adv_test.bb': 'SRC_URI += "git://foo.org/gaz.git;protocol=ssh;usehead=1"', }, @@ -33,6 +33,14 @@ class TestClassOelintVarsSRCURIReqOpt(TestBaseClass): 'oelint_adv_test.bb': 'SRC_URI += "gitsm://foo.org/gaz.git;protocol=ssh;usehead=1"', }, + { + 'oelint_adv_test.bb': + 'SRC_URI += "gomod://golang.org/x/net"', + }, + { + 'oelint_adv_test.bb': + 'SRC_URI += "gomodgit://golang.org/x/net"', + }, ], ) def test_bad(self, input_, id_, occurrence): @@ -91,6 +99,14 @@ def test_really_bad(self, input_, id_, occurrence): 'oelint_adv_test.bb': 'SRC_URI += "gitsm://foo.org/gaz.git;name=foo;protocol=ssh;branch=main;usehead=1"', }, + { + 'oelint_adv_test.bb': + 'SRC_URI += "gomod://golang.org/x/net;version=1.0"', + }, + { + 'oelint_adv_test.bb': + 'SRC_URI += "gomodgit://golang.org/x/net;version=1.0"', + }, { 'oelint-adv_test.bb': '''