Skip to content

Commit 8e778d8

Browse files
jacob-wienecke-nxpkartben
authored andcommitted
scripts: ci: check_compliance.py: Fix perl script running on windows
Add an if clause to the CheckPatch Class that checks for windows os. If windows os, check for perl installation. If no perl installation present. Fail the check. Without this change, CheckPatch can fail silently on windows, as windows does not have a way to run perl scripts. Signed-off-by: Jacob Wienecke <[email protected]>
1 parent 9791034 commit 8e778d8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

scripts/ci/check_compliance.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,29 @@ def run(self):
212212
if not os.path.exists(checkpatch):
213213
self.skip(f'{checkpatch} not found')
214214

215+
# check for Perl installation on Windows
216+
if os.name == 'nt':
217+
if not shutil.which('perl'):
218+
self.failure("Perl not installed - required for checkpatch.pl. Please install Perl or add to PATH.")
219+
return
220+
else:
221+
cmd = ['perl', checkpatch]
222+
223+
# Linux and MacOS
224+
else:
225+
cmd = [checkpatch]
226+
227+
cmd.extend(['--mailback', '--no-tree', '-'])
215228
diff = subprocess.Popen(('git', 'diff', '--no-ext-diff', COMMIT_RANGE),
216229
stdout=subprocess.PIPE,
217230
cwd=GIT_TOP)
218231
try:
219-
subprocess.run((checkpatch, '--mailback', '--no-tree', '-'),
232+
subprocess.run(cmd,
220233
check=True,
221234
stdin=diff.stdout,
222235
stdout=subprocess.PIPE,
223236
stderr=subprocess.STDOUT,
224-
shell=True, cwd=GIT_TOP)
237+
shell=False, cwd=GIT_TOP)
225238

226239
except subprocess.CalledProcessError as ex:
227240
output = ex.output.decode("utf-8")

0 commit comments

Comments
 (0)