summaryrefslogtreecommitdiff
path: root/buildscripts/resmokelib/reportfile.py
blob: 7dcf5623a6db2f957e6f8a582f34bb7c80b7c572 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Manages interactions with the report.json file.
"""

from __future__ import absolute_import

import json

from . import config
from .testing import report as _report


def write(suites):
    """
    Writes the combined report of all executions if --reportFile was
    specified on the command line.
    """

    if config.REPORT_FILE is None:
        return

    reports = []
    for suite in suites:
        reports.extend(suite.get_reports())

    combined_report_dict = _report.TestReport.combine(*reports).as_dict()
    with open(config.REPORT_FILE, "w") as fp:
        json.dump(combined_report_dict, fp)