@@ -291,37 +291,37 @@ def run(self):
291
291
cmd = [checkpatch ]
292
292
293
293
cmd .extend (['--mailback' , '--no-tree' , '-' ])
294
- diff = subprocess .Popen (('git' , 'diff' , '--no-ext-diff' , COMMIT_RANGE ),
294
+ with subprocess .Popen (('git' , 'diff' , '--no-ext-diff' , COMMIT_RANGE ),
295
295
stdout = subprocess .PIPE ,
296
- cwd = GIT_TOP )
297
- try :
298
- subprocess .run (cmd ,
299
- check = True ,
300
- stdin = diff .stdout ,
301
- stdout = subprocess .PIPE ,
302
- stderr = subprocess .STDOUT ,
303
- shell = False , cwd = GIT_TOP )
296
+ cwd = GIT_TOP ) as diff :
297
+ try :
298
+ subprocess .run (cmd ,
299
+ check = True ,
300
+ stdin = diff .stdout ,
301
+ stdout = subprocess .PIPE ,
302
+ stderr = subprocess .STDOUT ,
303
+ shell = False , cwd = GIT_TOP )
304
304
305
- except subprocess .CalledProcessError as ex :
306
- output = ex .output .decode ("utf-8" )
307
- regex = r'^\s*\S+:(\d+):\s*(ERROR|WARNING):(.+?):(.+)(?:\n|\r\n?)+' \
308
- r'^\s*#(\d+):\s*FILE:\s*(.+):(\d+):'
305
+ except subprocess .CalledProcessError as ex :
306
+ output = ex .output .decode ("utf-8" )
307
+ regex = r'^\s*\S+:(\d+):\s*(ERROR|WARNING):(.+?):(.+)(?:\n|\r\n?)+' \
308
+ r'^\s*#(\d+):\s*FILE:\s*(.+):(\d+):'
309
309
310
- matches = re .findall (regex , output , re .MULTILINE )
310
+ matches = re .findall (regex , output , re .MULTILINE )
311
311
312
- # add a guard here for excessive number of errors, do not try and
313
- # process each one of them and instead push this as one failure.
314
- if len (matches ) > 500 :
315
- self .failure (output )
316
- return
312
+ # add a guard here for excessive number of errors, do not try and
313
+ # process each one of them and instead push this as one failure.
314
+ if len (matches ) > 500 :
315
+ self .failure (output )
316
+ return
317
317
318
- for m in matches :
319
- self .fmtd_failure (m [1 ].lower (), m [2 ], m [5 ], m [6 ], col = None ,
320
- desc = m [3 ])
318
+ for m in matches :
319
+ self .fmtd_failure (m [1 ].lower (), m [2 ], m [5 ], m [6 ], col = None ,
320
+ desc = m [3 ])
321
321
322
- # If the regex has not matched add the whole output as a failure
323
- if len (matches ) == 0 :
324
- self .failure (output )
322
+ # If the regex has not matched add the whole output as a failure
323
+ if len (matches ) == 0 :
324
+ self .failure (output )
325
325
326
326
327
327
class BoardYmlCheck (ComplianceTest ):
0 commit comments