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

Fixed find command not working on Windows. #217

Merged
merged 1 commit into from
May 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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