Example #1
0
    def gather_report(self):
        """
    """
        assert (self.post_done == True)

        # -----------------------------------------------------------------
        for nodeid, report_list in self.mpi_reports.items():
            # print("nodeid::", nodeid)

            assert (len(report_list) > 0)

            # > Initialize with the first reporter
            i_rank_report_init, report_init = report_list[0]

            greport = TestReport(
                nodeid,
                report_init.location,
                report_init.keywords,
                report_init.outcome,
                report_init.longrepr,  # longrepr
                report_init.when)

            # print("report_init.location::", report_init.location)
            # print("report_init.longrepr::", type(report_init.longrepr), report_init.longrepr)

            collect_longrepr = []
            # > We need to rebuild a TestReport object, location can be false
            # > Report appears in rank increasing order
            if greport.outcome != 'skipped':
                # Skipped test are only know by proc 0 -> no merge required
                for i_rank_report, test_report in report_list:

                    if (test_report.outcome == 'failed'):
                        greport.outcome = test_report.outcome

                    if (test_report.longrepr):
                        fake_trace_back = ReprTraceback([
                            ReprEntryNative(
                                f"\n\n----------------------- On rank [{test_report._i_rank}/{test_report._n_rank}] / Global [{i_rank_report}/{self.comm.Get_size()}] ----------------------- \n\n"
                            )
                        ], None, None)
                        collect_longrepr.append(
                            (fake_trace_back,
                             ReprFileLocation(*report_init.location), None))
                        collect_longrepr.append(
                            (test_report.longrepr,
                             ReprFileLocation(*report_init.location), None))

                if (len(collect_longrepr) > 0):
                    greport.longrepr = ExceptionChainRepr(collect_longrepr)

            self.reports_gather[nodeid] = [greport]
Example #2
0
def _report_kwargs_from_json(reportdict: Dict[str, Any]) -> Dict[str, Any]:
    """Return **kwargs that can be used to construct a TestReport or
    CollectReport instance.

    This was originally the serialize_report() function from xdist (ca03269).
    """
    def deserialize_repr_entry(entry_data):
        data = entry_data["data"]
        entry_type = entry_data["type"]
        if entry_type == "ReprEntry":
            reprfuncargs = None
            reprfileloc = None
            reprlocals = None
            if data["reprfuncargs"]:
                reprfuncargs = ReprFuncArgs(**data["reprfuncargs"])
            if data["reprfileloc"]:
                reprfileloc = ReprFileLocation(**data["reprfileloc"])
            if data["reprlocals"]:
                reprlocals = ReprLocals(data["reprlocals"]["lines"])

            reprentry: Union[ReprEntry, ReprEntryNative] = ReprEntry(
                lines=data["lines"],
                reprfuncargs=reprfuncargs,
                reprlocals=reprlocals,
                reprfileloc=reprfileloc,
                style=data["style"],
            )
        elif entry_type == "ReprEntryNative":
            reprentry = ReprEntryNative(data["lines"])
        else:
            _report_unserialization_failure(entry_type, TestReport, reportdict)
        return reprentry

    def deserialize_repr_traceback(repr_traceback_dict):
        repr_traceback_dict["reprentries"] = [
            deserialize_repr_entry(x)
            for x in repr_traceback_dict["reprentries"]
        ]
        return ReprTraceback(**repr_traceback_dict)

    def deserialize_repr_crash(repr_crash_dict: Optional[Dict[str, Any]]):
        if repr_crash_dict is not None:
            return ReprFileLocation(**repr_crash_dict)
        else:
            return None

    if (reportdict["longrepr"] and "reprcrash" in reportdict["longrepr"]
            and "reprtraceback" in reportdict["longrepr"]):

        reprtraceback = deserialize_repr_traceback(
            reportdict["longrepr"]["reprtraceback"])
        reprcrash = deserialize_repr_crash(reportdict["longrepr"]["reprcrash"])
        if reportdict["longrepr"]["chain"]:
            chain = []
            for repr_traceback_data, repr_crash_data, description in reportdict[
                    "longrepr"]["chain"]:
                chain.append((
                    deserialize_repr_traceback(repr_traceback_data),
                    deserialize_repr_crash(repr_crash_data),
                    description,
                ))
            exception_info: Union[ExceptionChainRepr,
                                  ReprExceptionInfo] = ExceptionChainRepr(
                                      chain)
        else:
            exception_info = ReprExceptionInfo(reprtraceback, reprcrash)

        for section in reportdict["longrepr"]["sections"]:
            exception_info.addsection(*section)
        reportdict["longrepr"] = exception_info

    return reportdict