Skip to content

Commit 05100e1

Browse files
committed
tools: fix C++ import checker argument expansion
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]>
1 parent 2dbd15a commit 05100e1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tools/checkimports.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import io
66
import re
77
import sys
8-
8+
import itertools
99

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

4343
if __name__ == '__main__':
44-
files = glob.iglob(sys.argv[1] if len(sys.argv) > 1 else 'src/*.cc')
45-
sys.exit(0 if all(map(is_valid, files)) else 1)
44+
if len(sys.argv) > 1:
45+
files = []
46+
for pattern in sys.argv[1:]:
47+
files = itertools.chain(files, glob.iglob(pattern))
48+
else:
49+
files = glob.iglob('src/*.cc')
50+
sys.exit(0 if all(list(map(is_valid, files))) else 1)

0 commit comments

Comments
 (0)