| 257 | } |
| 258 | |
| 259 | void 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 | |
| 297 | void TJUnitProcessor::Save() { |
| 298 | MakeReportFileName(); |
nothing calls this directly
no test coverage detected