Bug 1787947 - pref on CSS named pages in Nightly r=dholbert
[gecko.git] / testing / parse_build_tests_ccov.py
blob985ed8e4bcc7662e55e69784205da5a4fe030a8a
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 from __future__ import absolute_import
8 import sys
9 import os
10 import pathlib
11 import shutil
12 import subprocess
13 import tempfile
14 import zipfile
15 import buildconfig
18 def main():
19 if not buildconfig.substs.get("MOZ_CODE_COVERAGE") or not buildconfig.substs.get(
20 "MOZ_RUST_TESTS"
22 return
24 assert (
25 "GRCOV_PATH" in os.environ
26 ), "The environment variable GRCOV_PATH should contain a path to grcov"
27 grcov_path = os.environ["GRCOV_PATH"]
28 assert os.path.exists(grcov_path), "grcov should exist"
30 grcov_command = [
31 grcov_path,
32 "-t",
33 "lcov",
34 "-p",
35 buildconfig.topsrcdir,
36 buildconfig.topobjdir,
39 if buildconfig.substs["OS_TARGET"] == "Linux":
40 gcc_dir = os.path.join(os.environ["MOZ_FETCHES_DIR"], "gcc")
41 if "LD_LIBRARY_PATH" in os.environ:
42 os.environ["LD_LIBRARY_PATH"] = "{}/lib64/:{}".format(
43 gcc_dir, os.environ["LD_LIBRARY_PATH"]
45 else:
46 os.environ["LD_LIBRARY_PATH"] = "{}/lib64/".format(gcc_dir)
48 os.environ["PATH"] = "{}/bin/{}{}".format(
49 gcc_dir, os.pathsep, os.environ["PATH"]
52 grcov_output = subprocess.check_output(grcov_command)
54 grcov_zip_path = os.path.join(buildconfig.topobjdir, "code-coverage-grcov.zip")
55 with zipfile.ZipFile(grcov_zip_path, "a", zipfile.ZIP_DEFLATED) as z:
56 z.writestr("grcov_lcov_output.info", grcov_output)
59 if __name__ == "__main__":
60 main()