Returns the name of the requested output file, or the default if none was explicitly specified.
| 424 | // Returns the name of the requested output file, or the default if none |
| 425 | // was explicitly specified. |
| 426 | std::string UnitTestOptions::GetAbsolutePathToOutputFile() { |
| 427 | const char* const gtest_output_flag = GTEST_FLAG(output).c_str(); |
| 428 | if (gtest_output_flag == NULL) |
| 429 | return ""; |
| 430 | |
| 431 | const char* const colon = strchr(gtest_output_flag, ':'); |
| 432 | if (colon == NULL) |
| 433 | return internal::FilePath::ConcatPaths( |
| 434 | internal::FilePath( |
| 435 | UnitTest::GetInstance()->original_working_dir()), |
| 436 | internal::FilePath(kDefaultOutputFile)).string(); |
| 437 | |
| 438 | internal::FilePath output_name(colon + 1); |
| 439 | if (!output_name.IsAbsolutePath()) |
| 440 | // TODO(wan@google.com): on Windows \some\path is not an absolute |
| 441 | // path (as its meaning depends on the current drive), yet the |
| 442 | // following logic for turning it into an absolute path is wrong. |
| 443 | // Fix it. |
| 444 | output_name = internal::FilePath::ConcatPaths( |
| 445 | internal::FilePath(UnitTest::GetInstance()->original_working_dir()), |
| 446 | internal::FilePath(colon + 1)); |
| 447 | |
| 448 | if (!output_name.IsDirectory()) |
| 449 | return output_name.string(); |
| 450 | |
| 451 | internal::FilePath result(internal::FilePath::GenerateUniqueFileName( |
| 452 | output_name, internal::GetCurrentExecutableName(), |
| 453 | GetOutputFormat().c_str())); |
| 454 | return result.string(); |
| 455 | } |
| 456 | |
| 457 | // Returns true iff the wildcard pattern matches the string. The |
| 458 | // first ':' or '\0' character in pattern marks the end of it. |
nothing calls this directly
no test coverage detected