|
6 | 6 | import glob
|
7 | 7 | import requests
|
8 | 8 | import argparse
|
| 9 | +import fnmatch |
9 | 10 | from time import sleep
|
10 | 11 | from json import loads
|
11 | 12 |
|
@@ -228,6 +229,26 @@ def _add_env_if_not_empty(lst, value):
|
228 | 229 | lst.add(value)
|
229 | 230 |
|
230 | 231 |
|
| 232 | +def find_files(directory, patterns, recursive=True, exclude_dirs=[]): |
| 233 | + if recursive: |
| 234 | + items = os.walk(directory, followlinks=False) |
| 235 | + else: |
| 236 | + items = [next(os.walk(directory, followLinks=False))] |
| 237 | + if not isinstance(patterns, list): |
| 238 | + patterns = [patterns] |
| 239 | + for root, dirs, files in items: |
| 240 | + dirs[:] = [d for d in dirs if d not in exclude_dirs] |
| 241 | + for basename in files: |
| 242 | + match = False |
| 243 | + for pattern in patterns: |
| 244 | + if fnmatch.fnmatch(basename, pattern): |
| 245 | + match = True |
| 246 | + break |
| 247 | + if match: |
| 248 | + filename = os.path.join(root, basename) |
| 249 | + yield filename |
| 250 | + |
| 251 | + |
231 | 252 | def generate_toc(root):
|
232 | 253 | res = (
|
233 | 254 | try_to_run(["git", "ls-files"], cwd=root)
|
@@ -869,30 +890,19 @@ def main(*argv, **kwargs):
|
869 | 890 | write("XX> Skip processing gcov")
|
870 | 891 |
|
871 | 892 | else:
|
872 |
| - dont_search_here = ( |
873 |
| - "-not -path './bower_components/**' " |
874 |
| - "-not -path './node_modules/**' " |
875 |
| - "-not -path './vendor/**'" |
876 |
| - ) |
877 |
| - write("==> Processing gcov (disable by -X gcov)") |
878 |
| - cmd = [ |
879 |
| - "find", |
880 |
| - (sanitize_arg("", codecov.gcov_root or root)), |
881 |
| - dont_search_here, |
882 |
| - "-type", |
883 |
| - "f", |
884 |
| - "-name", |
885 |
| - "*.gcno", |
886 |
| - " ".join(map(lambda a: "-not -path '%s'" % a, codecov.gcov_glob)), |
887 |
| - "-exec", |
888 |
| - (sanitize_arg("", codecov.gcov_exec or "")), |
889 |
| - "-pb", |
890 |
| - (sanitize_arg("", codecov.gcov_args or "")), |
891 |
| - "{}", |
892 |
| - "+", |
| 893 | + dont_search_here = [ |
| 894 | + "bower_components" |
| 895 | + "node_modules" |
| 896 | + "vendor" |
893 | 897 | ]
|
894 |
| - write(" Executing gcov (%s)" % cmd) |
895 |
| - try_to_run(cmd) |
| 898 | + if codecov.gcov_glob: |
| 899 | + dont_search_here.append(codecov.gcov_glob) |
| 900 | + |
| 901 | + write("==> Processing gcov (disable by -X gcov)") |
| 902 | + for path in find_files(sanitize_arg("", codecov.gcov_root or root), "*.gcno", True, dont_search_here): |
| 903 | + cmd = sanitize_arg("", codecov.gcov_exec or "") + " -pb " + sanitize_arg("", codecov.gcov_args or "") + " " + path |
| 904 | + write(" Executing gcov (%s)" % cmd) |
| 905 | + write(try_to_run(cmd)) |
896 | 906 |
|
897 | 907 | # Collect Reports
|
898 | 908 | # ---------------
|
|
0 commit comments