[CONCPP-102] Option to Disable Tests during Production Build Created: 2022-06-20  Updated: 2023-06-28  Resolved: 2023-06-28

Status: Closed
Project: MariaDB Connector/C++
Component/s: General
Affects Version/s: None
Fix Version/s: 1.0.3, 1.1.3

Type: Task Priority: Trivial
Reporter: Aaron Kimbrell Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Hi, could there be an option to enable/disable tests being built?
Like here
https://stackoverflow.com/questions/41737494/cmake-how-to-separately-compile-production-code-and-test-code



 Comments   
Comment by Lawrin Novitsky [ 2022-06-22 ]

Thank you for your report. I actually expected, that such option exists, since our other connectors usually have it, but it does not. I will add the option to suppress tests build. Not sure about only tests building - they are linked against the connector library.

As a workaround - you can simply remove test/CMakeLists.txt before running cmake. cmake should still normally execute, but test targets won't be created.

Comment by Lawrin Novitsky [ 2022-06-22 ]

I guess removing the whole test directory will have the same effect.

Comment by Aaron Kimbrell [ 2022-06-22 ]

yes, but it makes the git tree dirty, which is annoying.
you don't even have to remove the whole test folder, just the CMakeList in the test folder, and then it won't build test.
But a cmake flag would be a lot cleaner and standard

Comment by Lawrin Novitsky [ 2022-06-22 ]

As I said - it's only a workaround. And removing CMakeLists.txt only was my first variant.

Comment by Lawrin Novitsky [ 2023-06-28 ]

Added WITH_UNIT_TESTS option with default value ON to control if tests should be built.
Also added BUILD_TESTS_ONLY option(OFF) - it does what its names say. It just looked to be useful at least for me
Not sure if it makes sense to talk about fix version, but it will appear in source packages beginning from mentioned version - so, there is some sense

Generated at Thu Feb 08 03:08:21 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.