mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
+24
-4
@@ -911,25 +911,35 @@ void addDataSearchSubDirectory(const std::string& subdir)
|
||||
|
||||
static std::string findData(const std::string& relative_path, bool required, bool findDirectory)
|
||||
{
|
||||
#define TEST_TRY_FILE_WITH_PREFIX(prefix) \
|
||||
#define CHECK_FILE_WITH_PREFIX(prefix, result) \
|
||||
{ \
|
||||
result.clear(); \
|
||||
std::string path = path_join(prefix, relative_path); \
|
||||
/*printf("Trying %s\n", path.c_str());*/ \
|
||||
if (findDirectory) \
|
||||
{ \
|
||||
if (isDirectory(path)) \
|
||||
return path; \
|
||||
result = path; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
FILE* f = fopen(path.c_str(), "rb"); \
|
||||
if(f) { \
|
||||
fclose(f); \
|
||||
return path; \
|
||||
result = path; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define TEST_TRY_FILE_WITH_PREFIX(prefix) \
|
||||
{ \
|
||||
std::string result__; \
|
||||
CHECK_FILE_WITH_PREFIX(prefix, result__); \
|
||||
if (!result__.empty()) \
|
||||
return result__; \
|
||||
}
|
||||
|
||||
|
||||
const std::vector<std::string>& search_path = TS::ptr()->data_search_path;
|
||||
for(size_t i = search_path.size(); i > 0; i--)
|
||||
{
|
||||
@@ -956,7 +966,17 @@ static std::string findData(const std::string& relative_path, bool required, boo
|
||||
{
|
||||
const std::string& subdir = search_subdir[i - 1];
|
||||
std::string prefix = path_join(datapath, subdir);
|
||||
TEST_TRY_FILE_WITH_PREFIX(prefix);
|
||||
std::string result_;
|
||||
CHECK_FILE_WITH_PREFIX(prefix, result_);
|
||||
#if 1 // check for misused 'optional' mode
|
||||
if (!required && !result_.empty())
|
||||
{
|
||||
std::cout << "TEST ERROR: Don't use 'optional' findData() for " << relative_path << std::endl;
|
||||
CV_Assert(required || result_.empty());
|
||||
}
|
||||
#endif
|
||||
if (!result_.empty())
|
||||
return result_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,30 @@ static bool printTestTag = false;
|
||||
static std::vector<std::string> currentDirectTestTags, currentImpliedTestTags;
|
||||
static std::vector<const ::testing::TestInfo*> skipped_tests;
|
||||
|
||||
static std::map<std::string, int>& getTestTagsSkipCounts()
|
||||
{
|
||||
static std::map<std::string, int> testTagsSkipCounts;
|
||||
return testTagsSkipCounts;
|
||||
}
|
||||
static std::map<std::string, int>& getTestTagsSkipExtraCounts()
|
||||
{
|
||||
static std::map<std::string, int> testTagsSkipExtraCounts;
|
||||
return testTagsSkipExtraCounts;
|
||||
}
|
||||
static void increaseTagsSkipCount(const std::string& tag, bool isMain)
|
||||
{
|
||||
std::map<std::string, int>& counts = isMain ? getTestTagsSkipCounts() : getTestTagsSkipExtraCounts();
|
||||
std::map<std::string, int>::iterator i = counts.find(tag);
|
||||
if (i == counts.end())
|
||||
{
|
||||
counts[tag] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
i->second++;
|
||||
}
|
||||
}
|
||||
|
||||
static std::vector<std::string>& getTestTagsSkipList()
|
||||
{
|
||||
static std::vector<std::string> testSkipWithTags;
|
||||
@@ -33,6 +57,17 @@ static std::vector<std::string>& getTestTagsSkipList()
|
||||
return testSkipWithTags;
|
||||
}
|
||||
|
||||
void registerGlobalSkipTag(const std::string& skipTag)
|
||||
{
|
||||
std::vector<std::string>& skipTags = getTestTagsSkipList();
|
||||
for (size_t i = 0; i < skipTags.size(); ++i)
|
||||
{
|
||||
if (skipTag == skipTags[i])
|
||||
return; // duplicate
|
||||
}
|
||||
skipTags.push_back(skipTag);
|
||||
}
|
||||
|
||||
static std::vector<std::string>& getTestTagsForceList()
|
||||
{
|
||||
static std::vector<std::string> getTestTagsForceList;
|
||||
@@ -156,7 +191,27 @@ public:
|
||||
{
|
||||
if (!skipped_tests.empty())
|
||||
{
|
||||
std::cout << "[ SKIP ] " << skipped_tests.size() << " tests via tags" << std::endl;
|
||||
std::cout << "[ SKIPSTAT ] " << skipped_tests.size() << " tests via tags" << std::endl;
|
||||
const std::vector<std::string>& skipTags = getTestTagsSkipList();
|
||||
const std::map<std::string, int>& counts = getTestTagsSkipCounts();
|
||||
const std::map<std::string, int>& countsExtra = getTestTagsSkipExtraCounts();
|
||||
for (std::vector<std::string>::const_iterator i = skipTags.begin(); i != skipTags.end(); ++i)
|
||||
{
|
||||
int c1 = 0;
|
||||
std::map<std::string, int>::const_iterator i1 = counts.find(*i);
|
||||
if (i1 != counts.end()) c1 = i1->second;
|
||||
int c2 = 0;
|
||||
std::map<std::string, int>::const_iterator i2 = countsExtra.find(*i);
|
||||
if (i2 != countsExtra.end()) c2 = i2->second;
|
||||
if (c2 > 0)
|
||||
{
|
||||
std::cout << "[ SKIPSTAT ] TAG='" << *i << "' skip " << c1 << " tests (" << c2 << " times in extra skip list)" << std::endl;
|
||||
}
|
||||
else if (c1 > 0)
|
||||
{
|
||||
std::cout << "[ SKIPSTAT ] TAG='" << *i << "' skip " << c1 << " tests" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
skipped_tests.clear();
|
||||
}
|
||||
@@ -255,13 +310,14 @@ void checkTestTags()
|
||||
if (isTestTagForced(testTag))
|
||||
return;
|
||||
}
|
||||
std::string skip_message;
|
||||
for (size_t i = 0; i < testTags.size(); ++i)
|
||||
{
|
||||
const std::string& testTag = testTags[i];
|
||||
if (isTestTagSkipped(testTag, skipTag))
|
||||
{
|
||||
skipped_tests.push_back(::testing::UnitTest::GetInstance()->current_test_info());
|
||||
throw SkipTestException("Test with tag '" + testTag + "' is skipped ('" + skipTag + "' is in skip list)");
|
||||
increaseTagsSkipCount(skipTag, skip_message.empty());
|
||||
if (skip_message.empty()) skip_message = "Test with tag '" + testTag + "' is skipped ('" + skipTag + "' is in skip list)";
|
||||
}
|
||||
}
|
||||
const std::vector<std::string>& testTagsImplied = currentImpliedTestTags;
|
||||
@@ -270,10 +326,16 @@ void checkTestTags()
|
||||
const std::string& testTag = testTagsImplied[i];
|
||||
if (isTestTagSkipped(testTag, skipTag))
|
||||
{
|
||||
skipped_tests.push_back(::testing::UnitTest::GetInstance()->current_test_info());
|
||||
throw SkipTestException("Test with tag '" + testTag + "' is skipped ('" + skipTag + "' is in skip list)");
|
||||
increaseTagsSkipCount(skipTag, skip_message.empty());
|
||||
if (skip_message.empty()) skip_message = "Test with tag '" + testTag + "' is skipped (implied '" + skipTag + "' is in skip list)";
|
||||
}
|
||||
}
|
||||
|
||||
if (!skip_message.empty())
|
||||
{
|
||||
skipped_tests.push_back(::testing::UnitTest::GetInstance()->current_test_info());
|
||||
throw SkipTestException(skip_message);
|
||||
}
|
||||
}
|
||||
|
||||
static bool applyTestTagImpl(const std::string& tag, bool direct = false)
|
||||
|
||||
Reference in New Issue
Block a user