Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
Fixed find command not working on Windows. #167
Browse files Browse the repository at this point in the history
  • Loading branch information
nmoinvaz committed May 21, 2020
1 parent 94ae0a2 commit 65d596e
Showing 1 changed file with 33 additions and 23 deletions.
56 changes: 33 additions & 23 deletions codecov/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import glob
import requests
import argparse
import fnmatch
from time import sleep
from json import loads

Expand Down Expand Up @@ -228,6 +229,26 @@ def _add_env_if_not_empty(lst, value):
lst.add(value)


def find_files(directory, patterns, recursive=True, exclude_dirs=[]):
if recursive:
items = os.walk(directory, followlinks=False)
else:
items = [next(os.walk(directory, followLinks=False))]
if not isinstance(patterns, list):
patterns = [patterns]
for root, dirs, files in items:
dirs[:] = [d for d in dirs if d not in exclude_dirs]
for basename in files:
match = False
for pattern in patterns:
if fnmatch.fnmatch(basename, pattern):
match = True
break
if match:
filename = os.path.join(root, basename)
yield filename


def generate_toc(root):
res = (
try_to_run(["git", "ls-files"], cwd=root)
Expand Down Expand Up @@ -869,30 +890,19 @@ def main(*argv, **kwargs):
write("XX> Skip processing gcov")

else:
dont_search_here = (
"-not -path './bower_components/**' "
"-not -path './node_modules/**' "
"-not -path './vendor/**'"
)
write("==> Processing gcov (disable by -X gcov)")
cmd = [
"find",
(sanitize_arg("", codecov.gcov_root or root)),
dont_search_here,
"-type",
"f",
"-name",
"*.gcno",
" ".join(map(lambda a: "-not -path '%s'" % a, codecov.gcov_glob)),
"-exec",
(sanitize_arg("", codecov.gcov_exec or "")),
"-pb",
(sanitize_arg("", codecov.gcov_args or "")),
"{}",
"+",
dont_search_here = [
"bower_components"
"node_modules"
"vendor"
]
write(" Executing gcov (%s)" % cmd)
try_to_run(cmd)
if codecov.gcov_glob:
dont_search_here.append(codecov.gcov_glob)

write("==> Processing gcov (disable by -X gcov)")
for path in find_files(sanitize_arg("", codecov.gcov_root or root), "*.gcno", True, dont_search_here):
cmd = sanitize_arg("", codecov.gcov_exec or "") + " -pb " + sanitize_arg("", codecov.gcov_args or "") + " " + path
write(" Executing gcov (%s)" % cmd)
write(try_to_run(cmd))

# Collect Reports
# ---------------
Expand Down

0 comments on commit 65d596e

Please sign in to comment.