void AutowiringEnclosure::OnTestEnd(const testing::TestInfo& info) {
  // Verify we can grab the test case back out and that the pointer is correct:
  Autowired<TestInfoProxy> ti;
  Autowired<AutowiringEnclosureExceptionFilter> ecef;
  auto ctxt = ecef ? ecef->GetContext() : nullptr;

  // Unconditionally reset the global context as the current context
  AutoGlobalContext()->SetCurrent();

  // Global initialization tests are special, we don't bother checking closure principle on them:
  if(!strcmp("GlobalInitTest", info.test_case_name()))
    return;

  // Need to make sure we got back our exception filter before continuing:
  ASSERT_TRUE(ecef.IsAutowired()) << "Failed to find the enclosed context exception filter; unit test may have incorrectly reset the enclosing context before returning";

  // Now try to tear down the test context enclosure:
  ctxt->SignalShutdown();

  // Do not allow teardown to take more than 250 milliseconds or so
  if(!ctxt->Wait(std::chrono::milliseconds(250))) {
    // Critical error--took too long to tear down
    assert(false);
  }

  static const char s_autothrow[] = "AUTOTHROW_";
  if(!strncmp(s_autothrow, info.name(), ARRAYCOUNT(s_autothrow) - 1))
    // Throw expected, end here
    return;

  // If an exception occurred somewhere, report it:
  ASSERT_FALSE(ecef->m_excepted)
    << "An unhandled exception occurred in this context" << std::endl
    << "[" << (ecef->m_ti ? ecef->m_ti->name() : "unknown") << "] " << ecef->m_what;
}
 // Called after a test ends.
 virtual void OnTestEnd(const ::testing::TestInfo& test_info)
 {
     int numFailuresThisProc = 0;
     if(!test_info.result()->Passed())
     {
         numFailuresThisProc = 1;
     }
     int numTotalFailures = -1;
     int root = 0;
     MPI_Reduce(&numFailuresThisProc, &numTotalFailures, 1, MPI_INT, MPI_SUM, root, MPI_COMM_WORLD);
     if(mProcId == 0)
     {
         if(numTotalFailures == 0)
         {
             ColoredPrintf(COLOR_GREEN, "[       OK ] ");
         }
         else
         {
             int numProcs = -1;
             MPI_Comm_size(MPI_COMM_WORLD, &numProcs);
             ColoredPrintf(COLOR_RED, "[  FAILED  ] ");
             printf("on %d of %d procs ", numTotalFailures, numProcs);
             mNumFails++;
         }
         printf("%s.%s\n", test_info.test_case_name(), test_info.name());
         fflush(stdout);
     }
 }
示例#3
0
void PrettyResultPrinter::OnTestStart(const testing::TestInfo& pTestInfo)
{
  testing::Log::getOStream() << Color::GREEN
                             << "[ RUN      ] " << Color::WHITE;
  PrintCaseName(pTestInfo.getCaseName(), pTestInfo.getTestName());
  testing::Log::getOStream() << Color::RESET << std::endl;
}
 virtual void OnTestStart(const ::testing::TestInfo& test_info)
 {
     if(mProcId == 0)
     {
         printf("*** Starting test %s.%s.\n",
                 test_info.test_case_name(), test_info.name());
     }
 }
示例#5
0
void MinimalistPrinter::OnTestStart(const ::testing::TestInfo &test_info) {
  auto vp = test_info.value_param();
  auto tp = test_info.type_param();
  _impl->_current_test = std::string()
      + test_info.test_case_name() + "." + test_info.name()
      // Add type param or value param information when available
      + ((vp || tp) ? " " : "") + (vp ? vp: "") + (tp ? tp: "");
}
示例#6
0
    // Fired before the test starts.
    virtual void OnTestStart(const ::testing::TestInfo& test_info) 
    {
#ifdef __COVERAGESCANNER__
      __coveragescanner_clear(); 
      std::string test_name=
        std::string(test_info.test_case_name())
        + '/'
        + std::string(test_info.name());
      __coveragescanner_testname(test_name.c_str());
#endif
    }
示例#7
0
    // Fired after the test ends.
    virtual void OnTestEnd(const ::testing::TestInfo& test_info) 
    {
#ifdef __COVERAGESCANNER__
      __coveragescanner_teststate("UNKNOWN");
      if (test_info.result())
      {
        if (test_info.result()->Passed())
          __coveragescanner_teststate("PASSED");
        if (test_info.result()->Failed())
          __coveragescanner_teststate("FAILED");
      }
      __coveragescanner_save(); 
#endif
    }
示例#8
0
        virtual void OnTestEnd(const ::testing::TestInfo& testInfo)
        {
            std::stringstream s;
            std::string name = testInfo.name() ? testInfo.name() : "<unknown>";
            s << "***Ending test [" << GoogleTestCase << ":" << GoogleTestName << "]" << std::endl;
            BOOST_TEST_CHECKPOINT(s.str());
#if defined(UNICODE)
            std::string sstr = s.str();
            std::wstring ws(sstr.size(), L' ');
            ws.resize(mbstowcs(&ws[0], sstr.c_str(), sstr.size()));
            output_debug_string(ws.c_str());
#else
            output_debug_string(s.str().c_str());
#endif
            is_google_test = false;
            GoogleTestCase = "";
            GoogleTestName = "";
        }
示例#9
0
文件: tests.cpp 项目: cyrinux/eguan
 virtual void OnTestEnd(const ::testing::TestInfo& test) {
     if (test.result() && test.result()->Failed()) {
         cerr << "Test " << test.name() << " failed" << endl;
     }
 }
示例#10
0
文件: tests.cpp 项目: cyrinux/eguan
 virtual void OnTestStart(const ::testing::TestInfo& test) {
     cout << "Running test: " << test.name() << endl;
 }
示例#11
0
void PrettyResultPrinter::OnTestEnd(const testing::TestInfo& pTestInfo)
{
  // unit-test results
  if (pTestInfo.result().isPassed()) {
    testing::Log::getOStream() << Color::GREEN
                               << "[       OK ] \n";
  }
  if (pTestInfo.result().isFailed()) {
    testing::Log::getOStream() << Color::RED
                               << "[  FAILED  ] ";
    testing::TestResult::Reliability::const_iterator test =
                                    pTestInfo.result().reliability().begin();
    testing::TestResult::Reliability::const_iterator tEnd =
                                      pTestInfo.result().reliability().end();
    while (test != tEnd) {
      testing::Log::getOStream() << "\n" << Color::Bold(Color::YELLOW)
                                         << (*test)->filename()
                                         << ':'
                                         << (*test)->lineNumber()
                                         << ": ";
      switch ((*test)->type()) {
        case testing::TestPartResult::kFatalFailure: {
          testing::Log::getOStream()
                               << Color::RED
                               << "fatal: "
                               << Color::RESET << Color::Bold(Color::YELLOW)
                               << "failed to assert\n";
          break;
        }
        case testing::TestPartResult::kNonFatalFailure: {
          testing::Log::getOStream()
                               << Color::MAGENTA
                               << "error: "
                               << Color::RESET << Color::Bold(Color::YELLOW)
                               << "failed to expect\n";
          break;
        }
        default:
          break;
      }

      testing::Log::getOStream() << Color::RESET
                                 << (*test)->message();
      ++test;
    }
    testing::Log::getOStream() << std::endl;
  }

  // performance test results
  if (!pTestInfo.result().performance().empty()) {
    // timer's result
    testing::Log::getOStream() << Color::Bold(Color::BLUE)
                               << "[ TIME (ns)]";

    testing::TestResult::Performance::const_iterator perf =
                                      pTestInfo.result().performance().begin();
    testing::TestResult::Performance::const_iterator pEnd =
                                      pTestInfo.result().performance().end();

    while (perf != pEnd) {
      testing::Log::getOStream() << " " << std::setw(7)
                                 << (*perf)->getTimerNum();
      ++perf;
    }
    testing::Log::getOStream() << Color::RESET << std::endl;

    // perf_event's results
    testing::Log::getOStream() << Color::Bold(Color::BLUE)
                               << "[CXT SWITCH]";

    perf = pTestInfo.result().performance().begin();
    pEnd = pTestInfo.result().performance().end();

    while (perf != pEnd) {
      testing::Log::getOStream() << " " << std::setw(7)
                                 << (*perf)->getPerfEventNum();
      ++perf;
    }
    testing::Log::getOStream() << Color::RESET << std::endl;
  }
}
示例#12
0
 virtual void OnTestEnd(const ::testing::TestInfo& test_info) {
   if (test_info.result()->Failed())
     printf("##teamcity[testFailed name='%s']\n", test_info.name());
   printf("##teamcity[testFinished name='%s']\n", test_info.name());
 }
示例#13
0
 virtual void OnTestStart(const ::testing::TestInfo& test_info) {
   printf("##teamcity[testStarted name='%s']\n", test_info.name());
 }
示例#14
0
	virtual void OnTestEnd(const ::testing::TestInfo& test_info) {
		string testname = test_info.test_case_name();
		if (testname == "LEDWhiteDim") {
			ASSERT_LT(test_info.result()->elapsed_time(), 8000);
		}
	}