proxygen
testing::internal::UnitTestOptions Class Reference

#include <gtest-internal-inl.h>

Static Public Member Functions

static std::string GetOutputFormat ()
 
static std::string GetAbsolutePathToOutputFile ()
 
static bool PatternMatchesString (const char *pattern, const char *str)
 
static bool FilterMatchesTest (const std::string &test_case_name, const std::string &test_name)
 
static bool MatchesFilter (const std::string &name, const char *filter)
 
static std::string GetOutputFormat ()
 
static std::string GetAbsolutePathToOutputFile ()
 
static bool PatternMatchesString (const char *pattern, const char *str)
 
static bool FilterMatchesTest (const std::string &test_case_name, const std::string &test_name)
 
static bool MatchesFilter (const std::string &name, const char *filter)
 
static std::string GetOutputFormat ()
 
static std::string GetAbsolutePathToOutputFile ()
 
static bool PatternMatchesString (const char *pattern, const char *str)
 
static bool FilterMatchesTest (const std::string &test_case_name, const std::string &test_name)
 
static bool MatchesFilter (const std::string &name, const char *filter)
 

Detailed Description

Definition at line 373 of file gtest-internal-inl.h.

Member Function Documentation

bool testing::internal::UnitTestOptions::FilterMatchesTest ( const std::string test_case_name,
const std::string test_name 
)
static

Definition at line 502 of file gtest.cc.

References folly::pushmi::operators::filter, GTEST_FLAG, testing::kUniversalFilter, and string.

Referenced by testing::internal::UnitTestImpl::FilterTests(), testing::internal::ShouldRunTestCase(), and testing::internal::TearDownEnvironment().

503  {
504  const std::string& full_name = test_case_name + "." + test_name.c_str();
505 
506  // Split --gtest_filter at '-', if there is one, to separate into
507  // positive filter and negative filter portions
508  const char* const p = GTEST_FLAG(filter).c_str();
509  const char* const dash = strchr(p, '-');
510  std::string positive;
511  std::string negative;
512  if (dash == NULL) {
513  positive = GTEST_FLAG(filter).c_str(); // Whole string is a positive filter
514  negative = "";
515  } else {
516  positive = std::string(p, dash); // Everything up to the dash
517  negative = std::string(dash + 1); // Everything after the dash
518  if (positive.empty()) {
519  // Treat '-test1' as the same as '*-test1'
520  positive = kUniversalFilter;
521  }
522  }
523 
524  // A filter is a colon-separated list of patterns. It matches a
525  // test if any pattern in it matches the test.
526  return (MatchesFilter(full_name, positive.c_str()) &&
527  !MatchesFilter(full_name, negative.c_str()));
528 }
#define GTEST_FLAG(name)
Definition: gtest-port.h:2504
PUSHMI_INLINE_VAR constexpr detail::filter_fn filter
Definition: filter.h:75
static const char kUniversalFilter[]
Definition: gtest.cc:168
const char * string
Definition: Conv.cpp:212
static bool MatchesFilter(const std::string &name, const char *filter)
Definition: gtest.cc:479
static bool testing::internal::UnitTestOptions::FilterMatchesTest ( const std::string test_case_name,
const std::string test_name 
)
static
static bool testing::internal::UnitTestOptions::FilterMatchesTest ( const std::string test_case_name,
const std::string test_name 
)
static
std::string testing::internal::UnitTestOptions::GetAbsolutePathToOutputFile ( )
static

Definition at line 426 of file gtest.cc.

References testing::internal::FilePath::ConcatPaths(), testing::internal::FilePath::GenerateUniqueFileName(), testing::internal::GetCurrentExecutableName(), testing::UnitTest::GetInstance(), GTEST_FLAG, testing::internal::FilePath::IsAbsolutePath(), testing::internal::FilePath::IsDirectory(), gmock_output_test::output, and testing::internal::FilePath::string().

Referenced by testing::internal::UnitTestImpl::ConfigureXmlOutput(), testing::internal::ShouldRunTestCase(), and testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

426  {
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)
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 }
#define GTEST_FLAG(name)
Definition: gtest-port.h:2504
static FilePath ConcatPaths(const FilePath &directory, const FilePath &relative_path)
static std::string GetOutputFormat()
Definition: gtest.cc:414
const std::string & string() const
GTEST_API_ FilePath GetCurrentExecutableName()
Definition: gtest.cc:399
static FilePath GenerateUniqueFileName(const FilePath &directory, const FilePath &base_name, const char *extension)
static const char kDefaultOutputFile[]
Definition: gtest.cc:171
static UnitTest * GetInstance()
Definition: gtest.cc:3972
static std::string testing::internal::UnitTestOptions::GetAbsolutePathToOutputFile ( )
static
static std::string testing::internal::UnitTestOptions::GetAbsolutePathToOutputFile ( )
static
std::string testing::internal::UnitTestOptions::GetOutputFormat ( )
static

Definition at line 414 of file gtest.cc.

References GTEST_FLAG, gmock_output_test::output, and string.

Referenced by testing::internal::UnitTestImpl::ConfigureXmlOutput(), testing::internal::ShouldRunTestCase(), and testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

414  {
415  const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
416  if (gtest_output_flag == NULL) return std::string("");
417 
418  const char* const colon = strchr(gtest_output_flag, ':');
419  return (colon == NULL) ?
420  std::string(gtest_output_flag) :
421  std::string(gtest_output_flag, colon - gtest_output_flag);
422 }
#define GTEST_FLAG(name)
Definition: gtest-port.h:2504
::std::string string
Definition: gtest-port.h:1097
STL namespace.
const char * string
Definition: Conv.cpp:212
static std::string testing::internal::UnitTestOptions::GetOutputFormat ( )
static
static std::string testing::internal::UnitTestOptions::GetOutputFormat ( )
static
static bool testing::internal::UnitTestOptions::MatchesFilter ( const std::string name,
const char *  filter 
)
static
static bool testing::internal::UnitTestOptions::MatchesFilter ( const std::string name,
const char *  filter 
)
static
bool testing::internal::UnitTestOptions::MatchesFilter ( const std::string name,
const char *  filter 
)
static

Definition at line 479 of file gtest.cc.

References folly::pushmi::operators::filter.

Referenced by testing::internal::UnitTestImpl::FilterTests(), testing::internal::UnitTestImpl::GetTestCase(), testing::internal::TestCaseNameIs::operator()(), testing::internal::ShouldRunTestCase(), and testing::internal::TearDownEnvironment().

480  {
481  const char *cur_pattern = filter;
482  for (;;) {
483  if (PatternMatchesString(cur_pattern, name.c_str())) {
484  return true;
485  }
486 
487  // Finds the next pattern in the filter.
488  cur_pattern = strchr(cur_pattern, ':');
489 
490  // Returns if no more pattern can be found.
491  if (cur_pattern == NULL) {
492  return false;
493  }
494 
495  // Skips the pattern separater (the ':' character).
496  cur_pattern++;
497  }
498 }
PUSHMI_INLINE_VAR constexpr detail::filter_fn filter
Definition: filter.h:75
static bool PatternMatchesString(const char *pattern, const char *str)
Definition: gtest.cc:462
const char * name
Definition: http_parser.c:437
static bool testing::internal::UnitTestOptions::PatternMatchesString ( const char *  pattern,
const char *  str 
)
static
bool testing::internal::UnitTestOptions::PatternMatchesString ( const char *  pattern,
const char *  str 
)
static

Definition at line 462 of file gtest.cc.

Referenced by testing::internal::ShouldRunTestCase().

463  {
464  switch (*pattern) {
465  case '\0':
466  case ':': // Either ':' or '\0' marks the end of the pattern.
467  return *str == '\0';
468  case '?': // Matches any single character.
469  return *str != '\0' && PatternMatchesString(pattern + 1, str + 1);
470  case '*': // Matches any string (possibly empty) of characters.
471  return (*str != '\0' && PatternMatchesString(pattern, str + 1)) ||
472  PatternMatchesString(pattern + 1, str);
473  default: // Non-special character. Matches itself.
474  return *pattern == *str &&
475  PatternMatchesString(pattern + 1, str + 1);
476  }
477 }
static bool PatternMatchesString(const char *pattern, const char *str)
Definition: gtest.cc:462
static bool testing::internal::UnitTestOptions::PatternMatchesString ( const char *  pattern,
const char *  str 
)
static

The documentation for this class was generated from the following files: