MCPcopy Create free account
hub / github.com/catboost/catboost / MergeSubprocessReport

Method MergeSubprocessReport

library/cpp/testing/unittest/junit.cpp:645–771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

643}
644
645void TJUnitProcessor::MergeSubprocessReport() {
646 {
647 const i64 len = GetFileLength(TmpReportFile->Name());
648 if (len < 0) {
649 Cerr << "Failed to get length of the output file for subprocess" << Endl;
650 return;
651 }
652 if (len == 0) {
653 return; // Empty file
654 }
655 }
656
657 Y_DEFER {
658 TFile file(TmpReportFile->Name(), EOpenModeFlag::TruncExisting);
659 file.Close();
660 };
661
662 NJson::TJsonValue testsReportJson;
663 {
664 TFileInput in(TmpReportFile->Name());
665 if (!NJson::ReadJsonTree(&in, &testsReportJson)) {
666 Cerr << "Failed to read json report for subprocess" << Endl;
667 return;
668 }
669 }
670
671 if (!testsReportJson.IsMap()) {
672 Cerr << "Invalid subprocess report format: report is not a map" << Endl;
673 return;
674 }
675
676 const NJson::TJsonValue* testSuitesJson = nullptr;
677 if (!testsReportJson.GetValuePointer("testsuites"sv, &testSuitesJson)) {
678 // no tests for some reason
679 Cerr << "No tests found in subprocess report" << Endl;
680 return;
681 }
682
683 if (!testSuitesJson->IsArray()) {
684 Cerr << "Invalid subprocess report format: testsuites is not an array" << Endl;
685 return;
686 }
687
688 for (const NJson::TJsonValue& suiteJson : testSuitesJson->GetArray()) {
689 if (!suiteJson.IsMap()) {
690 Cerr << "Invalid subprocess report format: suite is not a map" << Endl;
691 continue;
692 }
693 const NJson::TJsonValue* suiteIdJson = nullptr;
694 if (!suiteJson.GetValuePointer("id"sv, &suiteIdJson)) {
695 Cerr << "Invalid subprocess report format: suite does not have id" << Endl;
696 continue;
697 }
698
699 const TString& suiteId = suiteIdJson->GetString();
700 if (suiteId.empty()) {
701 Cerr << "Invalid subprocess report format: suite has empty id" << Endl;
702 continue;

Callers

nothing calls this directly

Calls 13

GetFileLengthFunction · 0.85
fileFunction · 0.50
ReadJsonTreeFunction · 0.50
NameMethod · 0.45
CloseMethod · 0.45
IsMapMethod · 0.45
GetValuePointerMethod · 0.45
IsArrayMethod · 0.45
GetArrayMethod · 0.45
GetStringMethod · 0.45
emptyMethod · 0.45
GetDoubleMethod · 0.45

Tested by

no test coverage detected