Boost.Test test compilation faster

I use xcode (gcc) to compile my boost test package, and it takes too much time.

Tests are minimal dummy tests, but it takes a few seconds to compile them (about 20):

#include "boost/test/included/unit_test.hpp" BOOST_AUTO_TEST_CASE(dummy) { BOOST_CHECK_EQUAL(2+2, 4); } BOOST_AUTO_TEST_CASE(dummyFail) { BOOST_CHECK_EQUAL(2+3, 4); } 

The guide suggests using a library version to speed up compilation. However, I am worried that this might not work - xcode is already rebuilding my tests. The whole structure has not been compiled again, since object files exist.

I think this is the number of header and template files in Boost.Test that are responsible for most of the compilation time.

Do you have an idea how to compile much faster? Will use it as a library? Will it include only boost.test parts?

Any help is much appreciated!

+7
source share
2 answers

The reason for slow compilation is because boost/test/included/unit_test.hpp is huge. Using a library makes this faster because the huge header compiles when the library is built, not after. Then your tests include a smaller set of headers, which leads to a reduction in build time.

Since I'm too lazy to create a library, the alternative I used is to have one source file (which never changes and therefore rarely gets restored) includes a full boost test, and then has all real tests, sources only include boost/test/unit_test.hpp . This provides most of the benefits of using the library.

+7
source

Try using precompiled headers, this should reduce compilation time. Details can be found here: http://www.boost.org/boost-build2/doc/html/bbv2/reference/precompiled_headers.html

+2
source

All Articles