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 <jasnell@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
addaleax authored and codebytere committed Aug 11, 2020
1 parent e97fe4b commit af0cfeb
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 af0cfeb

Please sign in to comment.