ci: kconfig rules: Allow any file starting with KConfig.* to be sourced

This commit is contained in:
Angus Gratton 2019-08-14 10:21:53 +10:00 committed by Angus Gratton
parent 278c2f1aea
commit f8b1ef1b14
2 changed files with 7 additions and 6 deletions

View file

@ -94,11 +94,12 @@ class SourceChecker(BaseChecker):
raise InputError(self.path_in_idf, line_number, '"source" has to been followed by space', raise InputError(self.path_in_idf, line_number, '"source" has to been followed by space',
line.replace('source', 'source ')) line.replace('source', 'source '))
path = m.group(2) path = m.group(2)
filename = os.path.basename(path)
if path in ['$COMPONENT_KCONFIGS_PROJBUILD', '$COMPONENT_KCONFIGS']: if path in ['$COMPONENT_KCONFIGS_PROJBUILD', '$COMPONENT_KCONFIGS']:
pass pass
elif not path.endswith('/Kconfig.in') and path != 'Kconfig.in': elif not filename.startswith('Kconfig.'):
raise InputError(self.path_in_idf, line_number, "only Kconfig.in can be sourced", raise InputError(self.path_in_idf, line_number, "only filenames starting with Kconfig.* can be sourced",
line.replace(path, os.path.join(os.path.dirname(path), 'Kconfig.in'))) line.replace(path, os.path.join(os.path.dirname(path), 'Kconfig.' + filename)))
class LineRuleChecker(BaseChecker): class LineRuleChecker(BaseChecker):

View file

@ -80,10 +80,10 @@ class TestSourceChecker(unittest.TestCase, ApplyLine):
pass pass
def test_source_file_name(self): def test_source_file_name(self):
self.expect_error('source "Kconfig.test"', expect='source "Kconfig.in"') self.expect_error('source "notKconfig.test"', expect='source "Kconfig.notKconfig.test"')
self.expect_error('source "/tmp/Kconfig.test"', expect='source "/tmp/Kconfig.in"') self.expect_error('source "Kconfig"', expect='source "Kconfig.Kconfig"')
self.expect_error('source "Kconfig"', expect='source "Kconfig.in"')
self.expt_success('source "Kconfig.in"') self.expt_success('source "Kconfig.in"')
self.expt_success('source "/tmp/Kconfig.test"')
self.expt_success('source "/tmp/Kconfig.in"') self.expt_success('source "/tmp/Kconfig.in"')
self.expect_error('source"Kconfig.in"', expect='source "Kconfig.in"') self.expect_error('source"Kconfig.in"', expect='source "Kconfig.in"')
self.expt_success('source "/tmp/Kconfig.in" # comment') self.expt_success('source "/tmp/Kconfig.in" # comment')