joboccara / NamedType

Implementation of strong types in C++
MIT License
766 stars 85 forks source link

Make incremental compilation of tests 3x faster #46

Closed knatten closed 3 years ago

knatten commented 3 years ago

Catch 2 is a header only library, and doing #define CATCH_CONFIG_MAIN incurs quite a lot of work. It is recommended to not do this in the files containing actual tests, to avoid that cost on incremental builds when you're modifying your unit tests. (See https://github.com/catchorg/Catch2/blob/master/docs/slow-compiles.md#top)

This commit follows the approach suggested by the Catch 2 documentation. It removes #define CATCH_CONFIG_MAIN from tests.cpp, and adds a new main.cpp which only does #define CATCH_CONFIG_MAIN.

This brings incremental compilation of tests down from 6.6 seconds to 1.8 seconds on my (decently powerful) machine.

joboccara commented 3 years ago

Awesome, thanks for the PR!