Skip to content

Commit c5db6d7

Browse files
marc-hbnashif
authored andcommitted
check_compliance.py: fix broken exception handling in Kconfig
PR zephyrproject-rtos#42 / Commit 4a2a1e17a488 "Use zephyr_module.py to generate Kconfig.modules" totally failed to handle exceptions by trying to re-use bits of existing code which was meant for something completely different: - exception name mismatch ("ex" vs "e"); - irrelevant sh.CommandNotFound exception left over; - use of the low-level popen()/pcommunicate() which rarely ever raise exceptions; ... To reproduce the issue, temporarily rename 'scripts/zephyr_module.py' to something else and observe the Kconfig check silently passing despite the lack of the main script and thanks to a /tmp/Kconfig.modules file left behind by some previous run. Clean-up the mess and simplify the code thanks to the higher-level and recommended subprocess.check_output(). Maybe any /tmp/Kconfig.modules leftover should also be cleaned-up but that's a different issue. (This confirms the theory that error handling tends to have the worst test coverage) Signed-off-by: Marc Herbert <[email protected]>
1 parent af2a992 commit c5db6d7

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

scripts/ci/check_compliance.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,9 @@ def get_modules(self, modules_file):
213213
cmd = [sys.executable, zephyr_module_path,
214214
'--kconfig-out', modules_file]
215215
try:
216-
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
217-
stderr=subprocess.PIPE)
218-
p.communicate()
216+
_ = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
219217
except subprocess.CalledProcessError as ex:
220-
self.skip("Command not found: " + str(e))
221-
except sh.ErrorReturnCode as e:
222-
self.skip(e)
218+
self.error(ex.output)
223219

224220
def parse_kconfig(self):
225221
"""

0 commit comments

Comments
 (0)