| 820 | } |
| 821 | |
| 822 | void cmCTestMultiProcessHandler::UpdateCostData() |
| 823 | { |
| 824 | std::string fname = this->CTest->GetCostDataFile(); |
| 825 | std::string tmpout = fname + ".tmp"; |
| 826 | cmsys::ofstream fout; |
| 827 | fout.open(tmpout.c_str()); |
| 828 | |
| 829 | PropertiesMap temp = this->Properties; |
| 830 | |
| 831 | if (cmSystemTools::FileExists(fname)) { |
| 832 | cmsys::ifstream fin; |
| 833 | fin.open(fname.c_str()); |
| 834 | |
| 835 | std::string line; |
| 836 | while (std::getline(fin, line)) { |
| 837 | if (line == "---") { |
| 838 | break; |
| 839 | } |
| 840 | // Format: <name> <previous_runs> <avg_cost> |
| 841 | cm::optional<CostEntry> entry = splitCostLine(line); |
| 842 | if (!entry) { |
| 843 | break; |
| 844 | } |
| 845 | |
| 846 | int index = this->SearchByName(entry->name); |
| 847 | if (index == -1) { |
| 848 | // This test is not in memory. We just rewrite the entry |
| 849 | fout << entry->name << " " << entry->prevRuns << " " << entry->cost |
| 850 | << "\n"; |
| 851 | } else { |
| 852 | // Update with our new average cost |
| 853 | fout << entry->name << " " << this->Properties[index]->PreviousRuns |
| 854 | << " " << this->Properties[index]->Cost << "\n"; |
| 855 | temp.erase(index); |
| 856 | } |
| 857 | } |
| 858 | fin.close(); |
| 859 | cmSystemTools::RemoveFile(fname); |
| 860 | } |
| 861 | |
| 862 | // Add all tests not previously listed in the file |
| 863 | for (auto const& i : temp) { |
| 864 | fout << i.second->Name << " " << i.second->PreviousRuns << " " |
| 865 | << i.second->Cost << "\n"; |
| 866 | } |
| 867 | |
| 868 | // Write list of failed tests |
| 869 | fout << "---\n"; |
| 870 | for (std::string const& f : *this->Failed) { |
| 871 | fout << f << "\n"; |
| 872 | } |
| 873 | fout.close(); |
| 874 | cmSystemTools::RenameFile(tmpout, fname); |
| 875 | } |
| 876 | |
| 877 | void cmCTestMultiProcessHandler::ReadCostData() |
| 878 | { |
no test coverage detected