acts icon indicating copy to clipboard operation
acts copied to clipboard

test: Add option to only build matching unittests

Open benjaminhuth opened this issue 1 year ago • 8 comments

As we have a lot of unit tests, I find it convenient to only enable some of them during developement. This can be done like this with this PR:

cmake .. -D ACTS_BUILD_ONLY_MATCHING_UNITTESTS="ActsUnitTestGeo.*"

This will only build unit tests that match the pattern (regex).

benjaminhuth avatar May 29 '24 15:05 benjaminhuth

Could you provide some more details on a use-case? During my development, only 1 unit test changes and needs to be recompiled. Then I only execute that one.

edit: after discussion with @benjaminhuth, possible cases are:

  • switching between branches
  • fetching unrelated changes

AJPfleger avatar May 29 '24 15:05 AJPfleger

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 47.59%. Comparing base (2e0ebfe) to head (8451934). Report is 455 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3233      +/-   ##
==========================================
- Coverage   49.14%   47.59%   -1.55%     
==========================================
  Files         499      507       +8     
  Lines       29253    29135     -118     
  Branches    13870    13976     +106     
==========================================
- Hits        14375    13866     -509     
- Misses       4969     5268     +299     
- Partials     9909    10001      +92     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 29 '24 15:05 codecov[bot]

How do we proceed with this? My proposal is to just use something like

ninja -t targets | sed 's/:.*//g' | grep "ActsUnitTest.*" | xargs ninja

locally instead of adding this functionality to the cmake configuration.

paulgessinger avatar Jun 13 '24 15:06 paulgessinger

If we converge to use the regex targets, I would like to have a line in the documentation mentioning it.

AJPfleger avatar Jun 13 '24 15:06 AJPfleger

I guess one advantage of using CMake for this is that you do not have to explicitly build tests with ninja and the all target will just by default only build the tests which match. It reminds me a bit of the Athena mechanism to select packages to build. Maybe that would also be an option so we can have + and - listings. But that might be over-engineering

andiwand avatar Jun 13 '24 15:06 andiwand

I would be fine closing this, since most people seem fine with using ninja + regex, and this should also work fine for me. In the spirit "the less build system code the better". Adding a mechanism to do module selection with + / - listings sounds way to overengineered to me.

benjaminhuth avatar Jun 14 '24 06:06 benjaminhuth

If we contain it to the unit test macro + top level CMake option (so avoid having the extra ifs in the config) I'm on board with this. I also would stick to a single regex you supply with a single option.

paulgessinger avatar Jun 14 '24 07:06 paulgessinger

Let's close it for now, I don't have the motivation currently to make this clean. If I ever feel like needing this in the future, I can still reopen it.

benjaminhuth avatar Jul 17 '24 15:07 benjaminhuth