Skip to content

Commit b2cc4b9

Browse files
committed
Download the right grcov package for the platform where we are running the script
Fixes mozilla#376
1 parent 020fc57 commit b2cc4b9

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

report/firefox_code_coverage/codecoverage.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,29 @@ def download_grcov():
315315
)
316316
latest_tag = r["tag_name"]
317317

318-
if os.path.exists("grcov") and os.path.exists("grcov_ver"):
318+
if sys.platform.startswith("linux"):
319+
platform = "linux"
320+
grcov_path = "grcov"
321+
elif sys.platform == "darwin":
322+
platform = "osx"
323+
grcov_path = "grcov"
324+
elif sys.platform.startswith("win"):
325+
platform = "win"
326+
grcov_path = "grcov.exe"
327+
else:
328+
assert False, f"Unknown platform {sys.platform}"
329+
330+
if os.path.exists(grcov_path) and os.path.exists("grcov_ver"):
319331
with open("grcov_ver", "r") as f:
320332
installed_ver = f.read()
321333

322334
if installed_ver == latest_tag:
323-
return
335+
return grcov_path
324336

325337
urlretrieve(
326-
"https://github.com/marco-c/grcov/releases/download/%s/grcov-linux-x86_64.tar.bz2"
327-
% latest_tag,
338+
"https://github.com/marco-c/grcov/releases/download/{}/grcov-{}-x86_64.tar.bz2".format(
339+
latest_tag, platform
340+
),
328341
"grcov.tar.bz2",
329342
)
330343

@@ -337,6 +350,8 @@ def download_grcov():
337350
with open("grcov_ver", "w") as f:
338351
f.write(latest_tag)
339352

353+
return grcov_path
354+
340355

341356
def download_genhtml():
342357
if os.path.isdir("lcov"):
@@ -442,8 +457,7 @@ def main():
442457
if args.grcov:
443458
grcov_path = args.grcov
444459
else:
445-
download_grcov()
446-
grcov_path = "./grcov"
460+
grcov_path = download_grcov()
447461

448462
if args.stats:
449463
generate_report(grcov_path, "coveralls", "output.json", artifact_paths)

0 commit comments

Comments
 (0)