def ConvertProtoTraces(test_result, trace_processor_path): """Convert proto traces to json. For a test result with proto traces, converts them to json using trace_processor and stores the json trace as a separate artifact. """ artifacts = test_result.get('outputArtifacts', {}) proto_traces = [name for name in artifacts if _IsProtoTrace(name)] # TODO(crbug.com/990304): After implementation of TBMv3-style clock sync, # it will be possible to convert the aggregated proto trace, not # individual ones. for proto_trace_name in proto_traces: proto_file_path = artifacts[proto_trace_name]['filePath'] json_file_path = (os.path.splitext(proto_file_path)[0] + CONVERTED_JSON_SUFFIX) json_trace_name = (posixpath.splitext(proto_trace_name)[0] + CONVERTED_JSON_SUFFIX) trace_processor.ConvertProtoTraceToJson( trace_processor_path, proto_file_path, json_file_path) artifacts[json_trace_name] = { 'filePath': json_file_path, 'contentType': 'application/json', } logging.info('%s: Proto trace converted. Source: %s. Destination: %s.', test_result['testPath'], proto_file_path, json_file_path)
def testConvertProtoTraceToJson(self): with mock.patch('subprocess.check_call'): trace_processor.ConvertProtoTraceToJson(self.tp_path, '/path/to/proto', '/path/to/json')
def testConvertProtoTraceToJson(self): with mock.patch(RUN_METHOD): trace_processor.ConvertProtoTraceToJson(self.tp_path, '/path/to/proto', '/path/to/json')