diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp index 6675715224..e0388083fb 100644 --- a/modules/ts/include/opencv2/ts.hpp +++ b/modules/ts/include/opencv2/ts.hpp @@ -180,12 +180,21 @@ using testing::tuple_size; using testing::tuple_element; -class SkipTestException: public cv::Exception +namespace details { +class SkipTestExceptionBase: public cv::Exception +{ +public: + SkipTestExceptionBase(bool handlingTags); + SkipTestExceptionBase(const cv::String& message, bool handlingTags); +}; +} + +class SkipTestException: public details::SkipTestExceptionBase { public: int dummy; // workaround for MacOSX Xcode 7.3 bug (don't make class "empty") - SkipTestException() : dummy(0) {} - SkipTestException(const cv::String& message) : dummy(0) { this->msg = message; } + SkipTestException() : details::SkipTestExceptionBase(false), dummy(0) {} + SkipTestException(const cv::String& message) : details::SkipTestExceptionBase(message, false), dummy(0) { } }; /** Apply tag to the current test diff --git a/modules/ts/include/opencv2/ts/ts_ext.hpp b/modules/ts/include/opencv2/ts/ts_ext.hpp index ad4128581f..f920673d7a 100644 --- a/modules/ts/include/opencv2/ts/ts_ext.hpp +++ b/modules/ts/include/opencv2/ts/ts_ext.hpp @@ -16,6 +16,9 @@ extern int testThreads; void testSetUp(); void testTearDown(); + +bool checkBigDataTests(); + } // check for required "opencv_test" namespace @@ -37,7 +40,7 @@ void testTearDown(); Body(); \ CV__TEST_CLEANUP \ } \ - catch (const cvtest::SkipTestException& e) \ + catch (const cvtest::details::SkipTestExceptionBase& e) \ { \ printf("[ SKIP ] %s\n", e.what()); \ } \ @@ -74,9 +77,8 @@ void testTearDown(); #define CV__TEST_BIGDATA_BODY_IMPL(name) \ { \ - if (!cvtest::runBigDataTests) \ + if (!cvtest::checkBigDataTests()) \ { \ - printf("[ SKIP ] BigData tests are disabled\n"); \ return; \ } \ CV__TRACE_APP_FUNCTION_NAME(name); \ @@ -85,7 +87,7 @@ void testTearDown(); Body(); \ CV__TEST_CLEANUP \ } \ - catch (const cvtest::SkipTestException& e) \ + catch (const cvtest::details::SkipTestExceptionBase& e) \ { \ printf("[ SKIP ] %s\n", e.what()); \ } \ diff --git a/modules/ts/include/opencv2/ts/ts_perf.hpp b/modules/ts/include/opencv2/ts/ts_perf.hpp index 528b395eed..8512ec16f5 100644 --- a/modules/ts/include/opencv2/ts/ts_perf.hpp +++ b/modules/ts/include/opencv2/ts/ts_perf.hpp @@ -386,7 +386,7 @@ public: static enum PERF_STRATEGY getCurrentModulePerformanceStrategy(); static enum PERF_STRATEGY setModulePerformanceStrategy(enum PERF_STRATEGY strategy); - class PerfSkipTestException: public cv::Exception + class PerfSkipTestException: public cvtest::SkipTestException { public: int dummy; // workaround for MacOSX Xcode 7.3 bug (don't make class "empty") @@ -531,7 +531,7 @@ void PrintTo(const Size& sz, ::std::ostream* os); ::cvtest::testSetUp(); \ RunPerfTestBody(); \ } \ - catch (cvtest::SkipTestException& e) \ + catch (cvtest::details::SkipTestExceptionBase& e) \ { \ printf("[ SKIP ] %s\n", e.what()); \ } \ diff --git a/modules/ts/src/ts.cpp b/modules/ts/src/ts.cpp index 1c8deacbbc..406ee1f3be 100644 --- a/modules/ts/src/ts.cpp +++ b/modules/ts/src/ts.cpp @@ -125,6 +125,20 @@ bool required_opencv_test_namespace = false; // compilation check for non-refac namespace cvtest { +details::SkipTestExceptionBase::SkipTestExceptionBase(bool handlingTags) +{ + if (!handlingTags) + { + testTagIncreaseSkipCount("skip_other", true, true); + } +} +details::SkipTestExceptionBase::SkipTestExceptionBase(const cv::String& message, bool handlingTags) +{ + if (!handlingTags) + testTagIncreaseSkipCount("skip_other", true, true); + this->msg = message; +} + uint64 param_seed = 0x12345678; // real value is passed via parseCustomOptions function static std::string path_join(const std::string& prefix, const std::string& subpath) @@ -850,6 +864,17 @@ void testTearDown() } } +bool checkBigDataTests() +{ + if (!runBigDataTests) + { + testTagIncreaseSkipCount("skip_bigdata", true, true); + printf("[ SKIP ] BigData tests are disabled\n"); + return false; + } + return true; +} + void parseCustomOptions(int argc, char **argv) { const string command_line_keys = string( diff --git a/modules/ts/src/ts_perf.cpp b/modules/ts/src/ts_perf.cpp index 7771b25d09..37d6546363 100644 --- a/modules/ts/src/ts_perf.cpp +++ b/modules/ts/src/ts_perf.cpp @@ -2003,16 +2003,16 @@ void TestBase::RunPerfTestBody() implConf.GetImpl(); #endif } - catch(const SkipTestException&) - { - metrics.terminationReason = performance_metrics::TERM_SKIP_TEST; - throw; - } catch(const PerfSkipTestException&) { metrics.terminationReason = performance_metrics::TERM_SKIP_TEST; return; } + catch(const cvtest::details::SkipTestExceptionBase&) + { + metrics.terminationReason = performance_metrics::TERM_SKIP_TEST; + throw; + } catch(const PerfEarlyExitException&) { metrics.terminationReason = performance_metrics::TERM_INTERRUPT; diff --git a/modules/ts/src/ts_tags.cpp b/modules/ts/src/ts_tags.cpp index 4b775722c1..906f0d74c9 100644 --- a/modules/ts/src/ts_tags.cpp +++ b/modules/ts/src/ts_tags.cpp @@ -23,8 +23,10 @@ static std::map& getTestTagsSkipExtraCounts() static std::map testTagsSkipExtraCounts; return testTagsSkipExtraCounts; } -static void increaseTagsSkipCount(const std::string& tag, bool isMain) +void testTagIncreaseSkipCount(const std::string& tag, bool isMain, bool appendSkipTests) { + if (appendSkipTests) + skipped_tests.push_back(::testing::UnitTest::GetInstance()->current_test_info()); std::map& counts = isMain ? getTestTagsSkipCounts() : getTestTagsSkipExtraCounts(); std::map::iterator i = counts.find(tag); if (i == counts.end()) @@ -192,11 +194,14 @@ public: { if (!skipped_tests.empty()) { - std::cout << "[ SKIPSTAT ] " << skipped_tests.size() << " tests via tags" << std::endl; + std::cout << "[ SKIPSTAT ] " << skipped_tests.size() << " tests skipped" << std::endl; const std::vector& skipTags = getTestTagsSkipList(); const std::map& counts = getTestTagsSkipCounts(); const std::map& countsExtra = getTestTagsSkipExtraCounts(); - for (std::vector::const_iterator i = skipTags.begin(); i != skipTags.end(); ++i) + std::vector skipTags_all = skipTags; + skipTags_all.push_back("skip_bigdata"); + skipTags_all.push_back("skip_other"); + for (std::vector::const_iterator i = skipTags_all.begin(); i != skipTags_all.end(); ++i) { int c1 = 0; std::map::const_iterator i1 = counts.find(*i); @@ -301,7 +306,7 @@ void checkTestTags() if (found != tags.size()) { skipped_tests.push_back(::testing::UnitTest::GetInstance()->current_test_info()); - throw SkipTestException("Test tags don't pass required tags list (--test_tag parameter)"); + throw details::SkipTestExceptionBase("Test tags don't pass required tags list (--test_tag parameter)", true); } } } @@ -317,7 +322,7 @@ void checkTestTags() const std::string& testTag = testTags[i]; if (isTestTagSkipped(testTag, skipTag)) { - increaseTagsSkipCount(skipTag, skip_message.empty()); + testTagIncreaseSkipCount(skipTag, skip_message.empty()); if (skip_message.empty()) skip_message = "Test with tag '" + testTag + "' is skipped ('" + skipTag + "' is in skip list)"; } } @@ -327,7 +332,7 @@ void checkTestTags() const std::string& testTag = testTagsImplied[i]; if (isTestTagSkipped(testTag, skipTag)) { - increaseTagsSkipCount(skipTag, skip_message.empty()); + testTagIncreaseSkipCount(skipTag, skip_message.empty()); if (skip_message.empty()) skip_message = "Test with tag '" + testTag + "' is skipped (implied '" + skipTag + "' is in skip list)"; } } @@ -335,7 +340,7 @@ void checkTestTags() if (!skip_message.empty()) { skipped_tests.push_back(::testing::UnitTest::GetInstance()->current_test_info()); - throw SkipTestException(skip_message); + throw details::SkipTestExceptionBase(skip_message, true); } } diff --git a/modules/ts/src/ts_tags.hpp b/modules/ts/src/ts_tags.hpp index a1f8a3333a..265b097527 100644 --- a/modules/ts/src/ts_tags.hpp +++ b/modules/ts/src/ts_tags.hpp @@ -21,6 +21,8 @@ namespace cvtest { void activateTestTags(const cv::CommandLineParser& parser); +void testTagIncreaseSkipCount(const std::string& tag, bool isMain = true, bool appendSkipTests = false); + } // namespace #endif // OPENCV_TS_SRC_TAGS_HPP