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

Method MakeReportFileName

library/cpp/testing/unittest/junit.cpp:259–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259void TJUnitProcessor::MakeReportFileName() {
260 constexpr size_t MaxReps = 200;
261
262#if defined(_win_)
263 constexpr char DirSeparator = '\\';
264#else
265 constexpr char DirSeparator = '/';
266#endif
267
268 if (!ResultReportFileName.empty()) {
269 return;
270 }
271
272 if (GetIsForked() || !FileName.empty() && FileName.back() != DirSeparator) {
273 ResultReportFileName = FileName;
274 } else { // Directory is specified, => make unique report name
275 if (!FileName.empty()) {
276 NFs::MakeDirectoryRecursive(FileName);
277 }
278 for (size_t i = 0; i < MaxReps; ++i) {
279 TString uniqReportFileName = BuildFileName(i, GetFileExtension());
280 try {
281 TFile newUniqReportFile(uniqReportFileName, EOpenModeFlag::CreateNew);
282 newUniqReportFile.Close();
283 ResultReportFileName = std::move(uniqReportFileName);
284 break;
285 } catch (const TFileError&) {
286 // File already exists => try next name
287 }
288 }
289 }
290
291 if (ResultReportFileName.empty()) {
292 Cerr << "Could not find a vacant file name to write report for path " << FileName << ", maximum number of reports: " << MaxReps << Endl;
293 Y_ABORT("Cannot write report");
294 }
295}
296
297void TJUnitProcessor::Save() {
298 MakeReportFileName();

Callers

nothing calls this directly

Calls 5

MakeDirectoryRecursiveFunction · 0.85
moveFunction · 0.50
emptyMethod · 0.45
backMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected