MCPcopy Create free account
hub / github.com/ChaiScript/ChaiScript / runCurrentTest

Method runCurrentTest

unittests/catch.hpp:8783–8828  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8781 }
8782
8783 void RunContext::runCurrentTest(std::string & redirectedCout, std::string & redirectedCerr) {
8784 auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
8785 SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description);
8786 m_reporter->sectionStarting(testCaseSection);
8787 Counts prevAssertions = m_totals.assertions;
8788 double duration = 0;
8789 m_shouldReportUnexpected = true;
8790 m_lastAssertionInfo = { "TEST_CASE"_sr, testCaseInfo.lineInfo, StringRef(), ResultDisposition::Normal };
8791
8792 seedRng(*m_config);
8793
8794 Timer timer;
8795 try {
8796 if (m_reporter->getPreferences().shouldRedirectStdOut) {
8797 RedirectedStdOut redirectedStdOut;
8798 RedirectedStdErr redirectedStdErr;
8799 timer.start();
8800 invokeActiveTestCase();
8801 redirectedCout += redirectedStdOut.str();
8802 redirectedCerr += redirectedStdErr.str();
8803
8804 } else {
8805 timer.start();
8806 invokeActiveTestCase();
8807 }
8808 duration = timer.getElapsedSeconds();
8809 } catch (TestFailureException&) {
8810 // This just means the test was aborted due to failure
8811 } catch (...) {
8812 // Under CATCH_CONFIG_FAST_COMPILE, unexpected exceptions under REQUIRE assertions
8813 // are reported without translation at the point of origin.
8814 if( m_shouldReportUnexpected ) {
8815 AssertionReaction dummyReaction;
8816 handleUnexpectedInflightException( m_lastAssertionInfo, translateActiveException(), dummyReaction );
8817 }
8818 }
8819 Counts assertions = m_totals.assertions - prevAssertions;
8820 bool missingAssertions = testForMissingAssertions(assertions);
8821
8822 m_testCaseTracker->close();
8823 handleUnfinishedSections();
8824 m_messages.clear();
8825
8826 SectionStats testCaseSectionStats(testCaseSection, assertions, duration, missingAssertions);
8827 m_reporter->sectionEnded(testCaseSectionStats);
8828 }
8829
8830 void RunContext::invokeActiveTestCase() {
8831 FatalConditionHandler fatalConditionHandler; // Handle signals

Callers

nothing calls this directly

Calls 10

StringRefClass · 0.85
seedRngFunction · 0.85
translateActiveExceptionFunction · 0.85
startMethod · 0.80
getElapsedSecondsMethod · 0.80
sectionStartingMethod · 0.45
getPreferencesMethod · 0.45
strMethod · 0.45
closeMethod · 0.45
sectionEndedMethod · 0.45

Tested by

no test coverage detected