Boost.Test with a static library

Hello everyone,
after prying for any hints in the documentation and reading frustrating
mails in the archives for a while now, I get the feeling that this is a
very confusing topic.
My aim is to use a static library of boost.test because I need to
compile it a lot and the waiting time when using the header is just
frustrating.
So I added to the "Jamfile.v2" in "libs/test/build" under "requirements"
the following line:
<define>BOOST_TEST_ALTERNATIVE_INIT_API=1
Then I used boost.build and apart from a few warnings like:
./boost/test/detail/config.hpp:85:1: warning:
"BOOST_TEST_ALTERNATIVE_INIT_API" redefined
<command-line>: warning: this is the location of the previous definition
everything seemed alright. So I'm assuming I now have a static library
with this macro defined so it should use the alternative initialiser.
Then I tried the following code, which I mostly copied from the
documentation, except for adding two macros:
#define BOOST_TEST_NO_LIB
#define BOOST_TEST_ALTERNATIVE_INIT_API
#define BOOST_TEST_MODULE example
#include

On Thu, Nov 20, 2008 at 11:47 PM, Moritz Beber
Hello everyone, after prying for any hints in the documentation and reading frustrating mails in the archives for a while now, I get the feeling that this is a very confusing topic. My aim is to use a static library of boost.test because I need to compile it a lot and the waiting time when using the header is just frustrating.
I felt the same way until I switched to using the minimal test suite. http://www.boost.org/doc/libs/1_37_0/libs/test/doc/html/minimal.html It builds much faster and has all the testing features I use. Ken

Ken Smith wrote:
On Thu, Nov 20, 2008 at 11:47 PM, Moritz Beber
wrote: Hello everyone, after prying for any hints in the documentation and reading frustrating mails in the archives for a while now, I get the feeling that this is a very confusing topic. My aim is to use a static library of boost.test because I need to compile it a lot and the waiting time when using the header is just frustrating.
I felt the same way until I switched to using the minimal test suite.
I would be interested to know why.
http://www.boost.org/doc/libs/1_37_0/libs/test/doc/html/minimal.html
It builds much faster and has all the testing features I use.
I would not recommend anyone to use this component anymore. It's here for slightly esoteric reasons. It does not match to UTF neither in functionality nor convenience, but in majority of the case UTF is as simple. Gennadiy

On Fri, Nov 21, 2008 at 11:09 AM, Gennadiy Rozental
Ken Smith wrote:
On Thu, Nov 20, 2008 at 11:47 PM, Moritz Beber
wrote: Hello everyone, after prying for any hints in the documentation and reading frustrating mails in the archives for a while now, I get the feeling that this is a very confusing topic. My aim is to use a static library of boost.test because I need to compile it a lot and the waiting time when using the header is just frustrating.
I felt the same way until I switched to using the minimal test suite.
I would be interested to know why.
The builds simply took much longer with boost/test/included/unit_test.hpp and I wanted to do the least amount of fiddling with my build to use this package. I'm sad to hear the minimal test framework is not recommended as it was working just fine for me so far. Basically, I wanted to figure out how to do the least amount of work to implement unit testing so my colleages would push back as little as possible when I recommended they use it. More testing is better testing regardless of the mechanism. Ken

Ken Smith
On Fri, Nov 21, 2008 at 11:09 AM, Gennadiy Rozental
wrote:
Ken Smith wrote:
On Thu, Nov 20, 2008 at 11:47 PM, Moritz Beber
wrote: Hello everyone, after prying for any hints in the documentation and reading frustrating mails in the archives for a while now, I get the feeling that this is a very confusing topic. My aim is to use a static library of boost.test because I need to compile it a lot and the waiting time when using the header is just frustrating.
I felt the same way until I switched to using the minimal test suite.
I would be interested to know why.
The builds simply took much longer with boost/test/included/unit_test.hpp and I wanted to do the least amount of fiddling with my build to use this package.
How much longer it takes? In my experience on modern PC/Linux box the difference almost negligible. How difficult would it be to spend 10 min once and build the static library? In that case compilation time should b even better than minimal.hpp. IMO advantages way overweight, even if you do not need any advanced features immediately. Give it a shoot - you may find it useful.
I'm sad to hear the minimal test framework is not recommended as it was working just fine for me so far.
You are free to use it. It's not going anywhere. But from almost any standpoint you may find UTF better
Basically, I wanted to figure out how to do the least amount of work to implement unit testing so my colleages would push back as little as possible when I recommended they use it. More testing is better testing regardless of the mechanism.
With UTF you can get more from the testing. Gennadiy

Moritz Beber
Hello everyone,
Hello, guys I had to step away from support for a bit, but now I am planning to reply to all the posts.
after prying for any hints in the documentation
Should probably start here: http://www.boost.org/doc/libs/1_37_0/libs/test/doc/html/utf/user-guide/usage...
and reading frustrating mails in the archives for a while now, I get the feeling that this is a very confusing topic.
I don't think so. There was some confusion about dynamic library variant, but the static library was there from the beginning and never really changed much.
My aim is to use a static library of boost.test because I need to compile it a lot and the waiting time when using the header is just frustrating.
Reasonable.
So I added to the "Jamfile.v2" in "libs/test/build" under "requirements" the following line: <define>BOOST_TEST_ALTERNATIVE_INIT_API=1
Why? Didn't it work for you out of the box?
Then I used boost.build and apart from a few warnings like: ./boost/test/detail/config.hpp:85:1: warning: "BOOST_TEST_ALTERNATIVE_INIT_API" redefined
This is a bit fishy. This place is only related to the dynamic library variant. Though maybe Boost.Build builds both with single command and it's fine in that case.
Then I tried the following code, which I mostly copied from the documentation, except for adding two macros:
#define BOOST_TEST_NO_LIB #define BOOST_TEST_ALTERNATIVE_INIT_API #define BOOST_TEST_MODULE example #include
BOOST_AUTO_TEST_SUITE( test_suite1 )
BOOST_AUTO_TEST_CASE( test_case1 ) { BOOST_WARN( sizeof(int) < 4 ); }
...
When I try to compile, however, I get the following error:
/home/engineer/libs/boost/lib/libboost_unit_test_framework-gcc43-mt-1_37.a(unit_test_main.o):
In function `main': unit_test_main.cpp:(.text+0x2229): undefined reference to `init_unit_test()' collect2: ld returned 1 exit status
Works fine for me. I just tried and reproduce your exercise. Maybe clean build would help? Also try to see on results from preprocessor: check if init_unit_test is there. Genandiy
participants (3)
-
Gennadiy Rozental
-
Ken Smith
-
Moritz Beber