-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate test utilities between modules #2170
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2170 +/- ##
=======================================
Coverage 13.90% 13.90%
=======================================
Files 189 189
Lines 15813 15813
Branches 4169 4169
=======================================
Hits 2199 2199
Misses 13461 13461
Partials 153 153 Continue to review full report at Codecov.
|
My biggest issue with this PR is that it's solving two somewhat unrelated problems. The first is the problem that all tests are getting symbols from potentially unrelatedly libraries and that is prone to cause issues. At a minimum, it's just a bit ugly to link Graphics symbols into the System tests. The second problem is the desire to minimize compile time for those who aren't building all of SFML but still want to build the tests. I have previously explained why I don't like supporting this use case in #2050 so I won't repeat myself. I can get behind solving the first problem if the implementation is good. My most significant request is that if we do make the test infrastructure more complicated, we do it with a clear plan that will lead to complexity leveling out soon. I hope that as tests get more sophisticated, our testing infrastructure won't need continuous hacks to keep up. |
Thank you for your feedback @ChrisThrasher.
You are right. Regarding the first described problem, I see two solution:
I don't have strong arguments for one or the other. My preference went to the second option. That seems more consistent with the fact that SFML is a collection of libraries. If we choose the second solution like in this PR, then solving the second described problem is as simple as four
As I see it, the infrastructure suggested in this PR seems generic enough so that we do not have to constantly hack the build system to write more expressive tests. At least, that is my guess. |
7f069b6
to
3985212
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not in love with going back to optionally building tests but at least with this new scheme of having 1 util library per module, we can actually implement that in a reasonable fashion. I made a couple small remarks but not enough to stand in the way of my approval so long as most of the commits get squashed. Thanks, Kimci!
# add a new static library which provides a main function and testing utilities for SFML types | ||
# example: sfml_add_test_utils(sfml-window-test-utils | ||
# SOURCES TestUtilities/WindowUtil.hpp TestUtilities/WindowUtil.cpp | ||
# DEPENDS SFML::Window sfml-system-test-utils) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we need these comments anymore since all the users of this function reside in the same file. Same goes for sfml_add_test
's description comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a big difference if the code using those functions is in the same file or not.
A small description doesn't hurt IMHO.
source_group("" FILES ${THIS_SOURCES}) | ||
|
||
# create the target | ||
string(TOLOWER test-sfml-${module} target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about sfml_add_test_utils
also using this same naming logic where instead of providing a target name, you just provide the module name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was tempted to do it, but I think it might make the code a little less clear because it would be less obvious where the test utility library target names come from. But I don't feel strongly about it, I could be convinced otherwise.
Consider:
sfml_add_test_utils(sfml-system-test-utils ...)
target_include_directories(sfml-system-test-utils PUBLIC TestUtilities)
versus
sfml_add_test_utils(System ...)
target_include_directories(sfml-system-test-utils PUBLIC TestUtilities)
3985212
to
ffd061b
Compare
Rebased and cleaned up commit history. |
Description
For now, test utilities for all SFML modules are compiled in a single library, which means for example that tests for the System module are linked with Graphics testing utilities. That was ok because apparently the linker ignores what is not used in a static library, but that looks like a hack to me. It starts to be a problem with linker errors in the work in progress feature/test_graphics branch.
To fix the issue, one solution would be to have a single test executable for all modules instead of one per module.
Another solution is to have specialized test utility libraries for each module.
This is the approach I took with this PR.
As a bonus, it then becomes simple to enable testing when not all modules are built, which was required since #2050.
#2050 was motivated by simplicity, so I hope my PR adds only a reasonable amount of complexity.
How to test this PR?
CI