Skip test on SkipTestException at fixture's constructor (version 2)#24250
Skip test on SkipTestException at fixture's constructor (version 2)#24250asmorkalov merged 13 commits intoopencv:4.xfrom
Conversation
|
@opencv-alalek Do you agree to merge the patch? |
modules/ts/src/ts_tags.cpp
Outdated
| { | ||
| if (std::find(skipped_tests.begin(), skipped_tests.end(), | ||
| ::testing::UnitTest::GetInstance()->current_test_info()) != skipped_tests.end()) { | ||
| throw details::SkipTestExceptionBase(false); |
There was a problem hiding this comment.
@dkurt Why do we need this?
What is the usecase? (usage example of the problem)
There was a problem hiding this comment.
Initially found in G-API tets where findDataFile is used in tests constructor: https://github.com/dkurt/opencv/blob/609b045d8316166deae61908e0cbee87fb251a71/modules/gapi/test/infer/gapi_infer_ov_tests.cpp#L258-L259
There was a problem hiding this comment.
How does findDataFile() call checkTestTags()?
On failure findDataFile() throws CV_Error() or SkipTestException exception.
There was a problem hiding this comment.
You're right, findDataFile throws an exception but it is ignored on 4.x:
TEST(TestFixture2, should_skip) {
findDataFile("not_a_file.png", false);
}
struct TestFixture : public ::testing::Test {
TestFixture() {
printf("enter constructor\n");
findDataFile("not_a_file.png", false);
printf("finish constructor\n");
}
};
TEST_F(TestFixture, Body) {
printf("enter test body\n");
}$ ./bin/opencv_test_core --gtest_filter=TestFixture*
Note: Google Test filter = TestFixture*
[==========] Running 2 tests from 2 test cases.
[----------] Global test environment set-up.
[----------] 1 test from TestFixture2
[ RUN ] TestFixture2.should_skip
[ SKIP ] OpenCV tests: Can't find data file: not_a_file.png
[ OK ] TestFixture2.should_skip (0 ms)
[----------] 1 test from TestFixture2 (0 ms total)
[----------] 1 test from TestFixture
[ RUN ] TestFixture.Body
enter constructor
unknown file: Failure
C++ exception with description "OpenCV tests: Can't find data file: not_a_file.png" thrown in the test fixture's constructor.
[ FAILED ] TestFixture.Body (1 ms)
[----------] 1 test from TestFixture (1 ms total)
[----------] Global test environment tear-down
[ SKIPSTAT ] 2 tests skipped
[ SKIPSTAT ] TAG='skip_other' skip 2 tests
[==========] 2 tests from 2 test cases ran. (2 ms total)
[ PASSED ] 1 test.
[ FAILED ] 1 test, listed below:
[ FAILED ] TestFixture.Body
There was a problem hiding this comment.
In this PR checkTestTags is called for a dummy test object which returns by a factory if test fixture thrown SkipTestException.
There was a problem hiding this comment.
checkTestTagsis called for a dummy test object
Why not just throw SkipTestException instead?
Make sense to rename DummyTest to SkipThisTest.
There was a problem hiding this comment.
Were able to avoid this check for the case with exception at constructor. Exception at SetUp will probably require some isSkipped flag in GTEST_TEST_CLASS_NAME_ (will do by a next commit).
b15feee to
79bdb4d
Compare
opencv-alalek
left a comment
There was a problem hiding this comment.
Well done 👍 Thank you!
Skip test on SkipTestException at fixture's constructor (version 2) opencv#24250 ### Pull Request Readiness Checklist Another version of opencv#24186 (reverted by opencv#24223). Current implementation cannot handle skip exception at `static void SetUpTestCase` but works on `virtual void SetUp`. See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
Skip test on SkipTestException at fixture's constructor (version 2) opencv#24250 ### Pull Request Readiness Checklist Another version of opencv#24186 (reverted by opencv#24223). Current implementation cannot handle skip exception at `static void SetUpTestCase` but works on `virtual void SetUp`. See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
Pull Request Readiness Checklist
Another version of #24186 (reverted by #24223). Current implementation cannot handle skip exception at
static void SetUpTestCasebut works onvirtual void SetUp.See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.