Skip to content

Commit

Permalink
srcurioptions: update database
Browse files Browse the repository at this point in the history
- crate supports downloadfilename
- crcc proto -> protocol
- add gomod
- add gomodgit

Signed-off-by: Konrad Weihmann <[email protected]>
  • Loading branch information
priv-kweihmann committed Oct 13, 2024
1 parent 425b267 commit 18a4bbb
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 6 deletions.
24 changes: 22 additions & 2 deletions oelint_adv/rule_base/rule_var_src_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ def __init__(self) -> None:
'protocol',
'scmdata',
],
'crate': [],
'crate': [
'downloadfilename',
],
'crcc': [
'module',
'proto',
'protocol',
'vob',
],
'cvs': [
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -148,6 +166,8 @@ def __init__(self) -> None:
self._required_might_options = {
'git': ['protocol'],
'gitsm': ['protocol'],
'gomod': ['version'],
'gomodgit': ['version'],
}

self._required_unless_options = {
Expand Down
63 changes: 60 additions & 3 deletions tests/test_class_oelint_vars_srcurioptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
'crate': [
'apply',
'destsuffix',
'downloadfilename',
'name',
'patchdir',
'striplevel',
Expand All @@ -77,7 +78,7 @@
'module',
'name',
'patchdir',
'proto',
'protocol',
'striplevel',
'subdir',
'unpack',
Expand Down Expand Up @@ -176,6 +177,22 @@
'name',
'proto',
],
'gomod': [
'downloadfilename',
'mod',
'module',
'version',
],
'gomodgit': [
'bareclone',
'branch',
'module',
'nobranch',
'protocol',
'repo',
'srcrev',
'version',
],
'hg': [
'apply',
'destsuffix',
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand Down Expand Up @@ -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'])
Expand Down
18 changes: 17 additions & 1 deletion tests/test_class_oelint_vars_srcurireqopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,22 @@ 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"',
},
{
'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):
Expand Down Expand Up @@ -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':
'''
Expand Down

0 comments on commit 18a4bbb

Please sign in to comment.