Bug 1853320 [wpt PR 41940] - [FLEDGE] Split up runs of /trusted-scoring-signals.https...
[gecko.git] / testing / parse_build_tests_ccov.py
blob966b3602ff514e2459c11f59024e956b26d743d0
1 #!/usr/bin/env python
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 import sys
8 import os
9 import pathlib
10 import shutil
11 import subprocess
12 import tempfile
13 import zipfile
14 import buildconfig
17 def main():
18 if not buildconfig.substs.get("MOZ_CODE_COVERAGE") or not buildconfig.substs.get(
19 "MOZ_RUST_TESTS"
21 return
23 assert (
24 "GRCOV_PATH" in os.environ
25 ), "The environment variable GRCOV_PATH should contain a path to grcov"
26 grcov_path = os.environ["GRCOV_PATH"]
27 assert os.path.exists(grcov_path), "grcov should exist"
29 grcov_command = [
30 grcov_path,
31 "-t",
32 "lcov",
33 "-p",
34 buildconfig.topsrcdir,
35 buildconfig.topobjdir,
38 if buildconfig.substs["OS_TARGET"] == "Linux":
39 gcc_dir = os.path.join(os.environ["MOZ_FETCHES_DIR"], "gcc")
40 if "LD_LIBRARY_PATH" in os.environ:
41 os.environ["LD_LIBRARY_PATH"] = "{}/lib64/:{}".format(
42 gcc_dir, os.environ["LD_LIBRARY_PATH"]
44 else:
45 os.environ["LD_LIBRARY_PATH"] = "{}/lib64/".format(gcc_dir)
47 os.environ["PATH"] = "{}/bin/{}{}".format(
48 gcc_dir, os.pathsep, os.environ["PATH"]
51 grcov_output = subprocess.check_output(grcov_command)
53 grcov_zip_path = os.path.join(buildconfig.topobjdir, "code-coverage-grcov.zip")
54 with zipfile.ZipFile(grcov_zip_path, "a", zipfile.ZIP_DEFLATED) as z:
55 z.writestr("grcov_lcov_output.info", grcov_output)
58 if __name__ == "__main__":
59 main()