| 643 | } |
| 644 | |
| 645 | void 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; |
nothing calls this directly
no test coverage detected