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: https://github.com/nodejs/node/pull/34565

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Anna Henningsen 2020-07-31 17:59:38 +02:00 committed by Shelley Vohr
parent e97fe4b630
commit af0cfeb1bb
No known key found for this signature in database
GPG Key ID: F13993A75599653C

View File

@ -5,7 +5,7 @@ import glob
import io import io
import re import re
import sys import sys
import itertools
def do_exist(file_name, lines, imported): def do_exist(file_name, lines, imported):
if not any(not re.match('using \w+::{0};'.format(imported), line) and if not any(not re.match('using \w+::{0};'.format(imported), line) and
@ -41,5 +41,10 @@ def is_valid(file_name):
return valid return valid
if __name__ == '__main__': if __name__ == '__main__':
files = glob.iglob(sys.argv[1] if len(sys.argv) > 1 else 'src/*.cc') if len(sys.argv) > 1:
sys.exit(0 if all(map(is_valid, files)) else 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)