Skip to content

Commit

Permalink
Use a more unique name for the cover variable (bazel-contrib#1764)
Browse files Browse the repository at this point in the history
  • Loading branch information
ixdy authored and jayconrod committed Oct 12, 2018
1 parent 2b22d49 commit 6f55a50
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions go/private/actions/cover.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ load(
"structs",
)

def _sanitize(s):
"""Replaces /, -, and . with _."""
return s.replace("/", "_").replace("-", "_").replace(".", "_")

def emit_cover(go, source):
"""See go/toolchains.rst#cover for full documentation."""

Expand All @@ -40,8 +44,8 @@ def emit_cover(go, source):
_, pkgpath = effective_importpath_pkgpath(source.library)
srcname = pkgpath + "/" + orig.basename if pkgpath else orig.path

cover_var = "Cover_" + src.basename[:-3].replace("-", "_").replace(".", "_")
out = go.declare_file(go, path = cover_var, ext = ".cover.go")
cover_var = "Cover_%s_%s" % (_sanitize(pkgpath), _sanitize(src.basename[:-3]))
out = go.declare_file(go, path = "Cover_%s" % _sanitize(src.basename[:-3]), ext = ".cover.go")
covered_src_map.pop(src, None)
covered_src_map[out] = orig
covered.append(out)
Expand Down

0 comments on commit 6f55a50

Please sign in to comment.