Returns the name of the requested output file, or the default if none was explicitly specified.
| 402 | // Returns the name of the requested output file, or the default if none |
| 403 | // was explicitly specified. |
| 404 | std::string UnitTestOptions::GetAbsolutePathToOutputFile() { |
| 405 | const char* const gtest_output_flag = GTEST_FLAG(output).c_str(); |
| 406 | if (gtest_output_flag == NULL) |
| 407 | return ""; |
| 408 | |
| 409 | const char* const colon = strchr(gtest_output_flag, ':'); |
| 410 | if (colon == NULL) |
| 411 | return internal::FilePath::ConcatPaths( |
| 412 | internal::FilePath( |
| 413 | UnitTest::GetInstance()->original_working_dir()), |
| 414 | internal::FilePath(kDefaultOutputFile)).string(); |
| 415 | |
| 416 | internal::FilePath output_name(colon + 1); |
| 417 | if (!output_name.IsAbsolutePath()) |
| 418 | // TODO(wan@google.com): on Windows \some\path is not an absolute |
| 419 | // path (as its meaning depends on the current drive), yet the |
| 420 | // following logic for turning it into an absolute path is wrong. |
| 421 | // Fix it. |
| 422 | output_name = internal::FilePath::ConcatPaths( |
| 423 | internal::FilePath(UnitTest::GetInstance()->original_working_dir()), |
| 424 | internal::FilePath(colon + 1)); |
| 425 | |
| 426 | if (!output_name.IsDirectory()) |
| 427 | return output_name.string(); |
| 428 | |
| 429 | internal::FilePath result(internal::FilePath::GenerateUniqueFileName( |
| 430 | output_name, internal::GetCurrentExecutableName(), |
| 431 | GetOutputFormat().c_str())); |
| 432 | return result.string(); |
| 433 | } |
| 434 | |
| 435 | // Returns true iff the wildcard pattern matches the string. The |
| 436 | // first ':' or '\0' character in pattern marks the end of it. |
nothing calls this directly
no test coverage detected