Skip to content

Commit

Permalink
tools: fix C++ import checker argument expansion
Browse files Browse the repository at this point in the history
Makefile assumes that it can pass a list of files to the import
checker, whereas the import checker expects a single argument
that is interpreted as a blob.

Fix that mismatch by accepting multiple arguments in the import
checker.

Refs: #34565

PR-URL: #34582
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
addaleax committed Aug 8, 2020
1 parent 2dbd15a commit 05100e1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tools/checkimports.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import io
import re
import sys

import itertools

def do_exist(file_name, lines, imported):
if not any(not re.match('using \w+::{0};'.format(imported), line) and
Expand Down Expand Up @@ -41,5 +41,10 @@ def is_valid(file_name):
return valid

if __name__ == '__main__':
files = glob.iglob(sys.argv[1] if len(sys.argv) > 1 else 'src/*.cc')
sys.exit(0 if all(map(is_valid, files)) else 1)
if len(sys.argv) > 1:
files = []
for pattern in sys.argv[1:]:
files = itertools.chain(files, glob.iglob(pattern))
else:
files = glob.iglob('src/*.cc')
sys.exit(0 if all(list(map(is_valid, files))) else 1)

0 comments on commit 05100e1

Please sign in to comment.