Factor out get_source_files in the tools.
Before this patch, lint.py would scan all C++ files present in HEAD
(but with any modifications from the working directory), whilst
clang_format.py would look at all C++ files without consulting Git.
This patch introduces a `get_source_files` utility, now used by both
scripts, which looks only at the file system.
This means that lint.py will now scan untracked files, but since
clang_format.py already did that (and would cause test.py to fail if
they weren't properly formatted), this seems to be reasonable behaviour.
The alternative -- looking at files known to Git -- is attractive, but
it could be misleading because we scan the state of those files in the
working directory, not in Git's HEAD.
Change-Id: I88ab245c6452b5bdf3e8ffa3eabb223cc9339f3e
diff --git a/tools/test.py b/tools/test.py
index 0d6bcb8..c4a43c7 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -250,16 +250,15 @@
def RunLinter(jobs):
- rc, default_tracked_files = lint.GetDefaultFilesToLint()
- if rc:
- return rc
- return lint.RunLinter(map(lambda x: join(dir_root, x), default_tracked_files),
+ return lint.RunLinter(map(lambda x: join(dir_root, x),
+ util.get_source_files()),
jobs = args.jobs, progress_prefix = 'cpp lint: ')
def RunClangFormat(clang_path, jobs):
- return clang_format.ClangFormatFiles(clang_format.GetCppSourceFilesToFormat(),
- clang_path, jobs = jobs,
+ return clang_format.ClangFormatFiles(util.get_source_files(),
+ clang_path,
+ jobs = jobs,
progress_prefix = 'clang-format: ')