From 337f806fbae3aa3147ec9f8f529f94577d85288c Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Thu, 9 Jun 2022 00:24:36 +0300 Subject: [PATCH] Turn some error conditions into assertions (part 2) --- kconfig_hardened_check/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kconfig_hardened_check/__init__.py b/kconfig_hardened_check/__init__.py index 45bd9d5..635397e 100644 --- a/kconfig_hardened_check/__init__.py +++ b/kconfig_hardened_check/__init__.py @@ -252,9 +252,10 @@ class OR(ComplexOptCheck): self.result = 'OK: {} not found'.format(opt.name) elif opt.result == 'OK: is present': self.result = 'OK: {} is present'.format(opt.name) - # VersionCheck provides enough info - elif not opt.result.startswith('OK: version'): - sys.exit('[!] ERROR: unexpected OK description "{}"'.format(opt.result)) + else: + # VersionCheck provides enough info + assert(opt.result.startswith('OK: version')), \ + 'unexpected OK description "{}"'.format(opt.result) return self.result = self.opts[0].result @@ -282,8 +283,8 @@ class AND(ComplexOptCheck): else: # VersionCheck provides enough info self.result = opt.result - if not opt.result.startswith('FAIL: version'): - sys.exit('[!] ERROR: unexpected FAIL description "{}"'.format(opt.result)) + assert(opt.result.startswith('FAIL: version')), \ + 'unexpected FAIL description "{}"'.format(opt.result) return -- 2.31.1