Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include/internal
diff options
context:
space:
mode:
authorPhil Nash2014-12-22 20:10:33 +0000
committerPhil Nash2014-12-22 20:10:33 +0000
commit7619920f860645dbd1d71ec44c9f76893bdff2f1 (patch)
treee0d84dfbb7972a92c6e88fad5dd3e6fe4dc5369b /include/internal
parent58dcb5ea928024544039babe8cdafcaf0c78c5ea (diff)
downloadcatch3-7619920f860645dbd1d71ec44c9f76893bdff2f1.tar.gz
Support for reporting skipped tests
- implemented by TeamCity reporter
Diffstat (limited to 'include/internal')
-rw-r--r--include/internal/catch_interfaces_reporter.h2
-rw-r--r--include/internal/catch_interfaces_testcase.h2
-rw-r--r--include/internal/catch_legacy_reporter_adapter.h1
-rw-r--r--include/internal/catch_legacy_reporter_adapter.hpp2
-rw-r--r--include/internal/catch_test_case_registry_impl.hpp23
5 files changed, 20 insertions, 10 deletions
diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h
index 6e058bf0..5296177a 100644
--- a/include/internal/catch_interfaces_reporter.h
+++ b/include/internal/catch_interfaces_reporter.h
@@ -244,6 +244,8 @@ namespace Catch
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0;
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0;
virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
+
+ virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
};
diff --git a/include/internal/catch_interfaces_testcase.h b/include/internal/catch_interfaces_testcase.h
index 21ed3c3a..a23ff9f4 100644
--- a/include/internal/catch_interfaces_testcase.h
+++ b/include/internal/catch_interfaces_testcase.h
@@ -28,7 +28,7 @@ namespace Catch {
struct ITestCaseRegistry {
virtual ~ITestCaseRegistry();
virtual std::vector<TestCase> const& getAllTests() const = 0;
- virtual void getFilteredTests( TestSpec const& testSpec, IConfig const& config, std::vector<TestCase>& matchingTestCases ) const = 0;
+ virtual void getFilteredTests( TestSpec const& testSpec, IConfig const& config, std::vector<TestCase>& matchingTestCases, bool negated = false ) const = 0;
};
}
diff --git a/include/internal/catch_legacy_reporter_adapter.h b/include/internal/catch_legacy_reporter_adapter.h
index fb579c7c..72c43d7d 100644
--- a/include/internal/catch_legacy_reporter_adapter.h
+++ b/include/internal/catch_legacy_reporter_adapter.h
@@ -50,6 +50,7 @@ namespace Catch
virtual void testCaseEnded( TestCaseStats const& testCaseStats );
virtual void testGroupEnded( TestGroupStats const& testGroupStats );
virtual void testRunEnded( TestRunStats const& testRunStats );
+ virtual void skipTest( TestCaseInfo const& );
private:
Ptr<IReporter> m_legacyReporter;
diff --git a/include/internal/catch_legacy_reporter_adapter.hpp b/include/internal/catch_legacy_reporter_adapter.hpp
index 09f73b28..6034581e 100644
--- a/include/internal/catch_legacy_reporter_adapter.hpp
+++ b/include/internal/catch_legacy_reporter_adapter.hpp
@@ -77,6 +77,8 @@ namespace Catch
void LegacyReporterAdapter::testRunEnded( TestRunStats const& testRunStats ) {
m_legacyReporter->EndTesting( testRunStats.totals );
}
+ void LegacyReporterAdapter::skipTest( TestCaseInfo const& ) {
+ }
}
#endif // TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_H_INCLUDED
diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp
index 6c01a187..21165a30 100644
--- a/include/internal/catch_test_case_registry_impl.hpp
+++ b/include/internal/catch_test_case_registry_impl.hpp
@@ -67,33 +67,38 @@ namespace Catch {
return m_nonHiddenFunctions;
}
- virtual void getFilteredTests( TestSpec const& testSpec, IConfig const& config, std::vector<TestCase>& matchingTestCases ) const {
+ virtual void getFilteredTests( TestSpec const& testSpec, IConfig const& config, std::vector<TestCase>& matchingTestCases, bool negated = false ) const {
for( std::vector<TestCase>::const_iterator it = m_functionsInOrder.begin(),
itEnd = m_functionsInOrder.end();
it != itEnd;
++it ) {
- if( testSpec.matches( *it ) && ( config.allowThrows() || !it->throws() ) )
+ bool includeTest = testSpec.matches( *it ) && ( config.allowThrows() || !it->throws() );
+ if( includeTest != negated )
matchingTestCases.push_back( *it );
}
+ sortTests( config, matchingTestCases );
+ }
+
+ private:
+
+ static void sortTests( IConfig const& config, std::vector<TestCase>& matchingTestCases ) {
+
switch( config.runOrder() ) {
case RunTests::InLexicographicalOrder:
std::sort( matchingTestCases.begin(), matchingTestCases.end(), LexSort() );
break;
case RunTests::InRandomOrder:
- {
- RandomNumberGenerator rng;
- std::random_shuffle( matchingTestCases.begin(), matchingTestCases.end(), rng );
- }
+ {
+ RandomNumberGenerator rng;
+ std::random_shuffle( matchingTestCases.begin(), matchingTestCases.end(), rng );
+ }
break;
case RunTests::InDeclarationOrder:
// already in declaration order
break;
}
}
-
- private:
-
std::set<TestCase> m_functions;
std::vector<TestCase> m_functionsInOrder;
std::vector<TestCase> m_nonHiddenFunctions;