From f8b1ef1b14d9392a8356e7d7ce7667f0f383536f Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 14 Aug 2019 10:21:53 +1000 Subject: [PATCH] ci: kconfig rules: Allow any file starting with KConfig.* to be sourced --- tools/check_kconfigs.py | 7 ++++--- tools/test_check_kconfigs.py | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/check_kconfigs.py b/tools/check_kconfigs.py index bdc3953e4..93754b705 100755 --- a/tools/check_kconfigs.py +++ b/tools/check_kconfigs.py @@ -94,11 +94,12 @@ class SourceChecker(BaseChecker): raise InputError(self.path_in_idf, line_number, '"source" has to been followed by space', line.replace('source', 'source ')) path = m.group(2) + filename = os.path.basename(path) if path in ['$COMPONENT_KCONFIGS_PROJBUILD', '$COMPONENT_KCONFIGS']: pass - elif not path.endswith('/Kconfig.in') and path != 'Kconfig.in': - raise InputError(self.path_in_idf, line_number, "only Kconfig.in can be sourced", - line.replace(path, os.path.join(os.path.dirname(path), 'Kconfig.in'))) + elif not filename.startswith('Kconfig.'): + 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.' + filename))) class LineRuleChecker(BaseChecker): diff --git a/tools/test_check_kconfigs.py b/tools/test_check_kconfigs.py index a38f16ab9..b8541e4a6 100755 --- a/tools/test_check_kconfigs.py +++ b/tools/test_check_kconfigs.py @@ -80,10 +80,10 @@ class TestSourceChecker(unittest.TestCase, ApplyLine): pass def test_source_file_name(self): - self.expect_error('source "Kconfig.test"', expect='source "Kconfig.in"') - self.expect_error('source "/tmp/Kconfig.test"', expect='source "/tmp/Kconfig.in"') - self.expect_error('source "Kconfig"', expect='source "Kconfig.in"') + self.expect_error('source "notKconfig.test"', expect='source "Kconfig.notKconfig.test"') + self.expect_error('source "Kconfig"', expect='source "Kconfig.Kconfig"') self.expt_success('source "Kconfig.in"') + self.expt_success('source "/tmp/Kconfig.test"') self.expt_success('source "/tmp/Kconfig.in"') self.expect_error('source"Kconfig.in"', expect='source "Kconfig.in"') self.expt_success('source "/tmp/Kconfig.in" # comment')