Jamfiles for unit tests

View: New views
9 Messages — Rating Filter:   Alert me  

Jamfiles for unit tests

by Boris Schaeling :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What are the recommendations to write Jamfiles for unit tests? I wonder as  
I tried something like this first:

----------
import boost ;
import testing ;

boost.use-project ;
project : requirements <library>/boost//test ;
unit-test mytest : mytest.cpp ;
----------

The linker (MSVC) complains it can't find the library (eg.  
libboost_test-vc90-mt-gd-1_39.lib). There seems to be something wrong with  
the target /boost//test (it exists but wrong files are looked up).  
Wondering how the unit tests of the Boost libraries work I found the  
test-suite rule. I rewrote my Jamfile to:

----------
import boost ;
import testing ;

boost.use-project ;
project : requirements <library>/boost//filesystem ;
test-suite mytest : [ run mytest.cpp ] ;
----------

This works. I have to reference another Boost library (like  
/boost//filesystem) but then the Boost.Test libraries are automatically  
found and linked (not with toolsets though which don't support  
auto-linking).

So what's the difference between unit-test and test-suite? Anything  
recommended because the other is deprecated? And how do I refer to the  
Boost.Test libraries (all the other targets like /boost//filesystem work)?

Boris

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Jamfiles for unit tests

by Steven Watanabe-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

AMDG

Boris Schaeling wrote:

> What are the recommendations to write Jamfiles for unit tests? I
> wonder as I tried something like this first:
>
> ----------
> import boost ;
> import testing ;
>
> boost.use-project ;
> project : requirements <library>/boost//test ;
> unit-test mytest : mytest.cpp ;
> ----------
>
> The linker (MSVC) complains it can't find the library (eg.
> libboost_test-vc90-mt-gd-1_39.lib). There seems to be something wrong
> with the target /boost//test (it exists but wrong files are looked up).

Try adding <define>BOOST_ALL_NO_LIB to the project requirements.

> Wondering how the unit tests of the Boost libraries work I found the
> test-suite rule. I rewrote my Jamfile to:
>
> ----------
> import boost ;
> import testing ;
>
> boost.use-project ;
> project : requirements <library>/boost//filesystem ;
> test-suite mytest : [ run mytest.cpp ] ;
> ----------
>
> This works. I have to reference another Boost library (like
> /boost//filesystem) but then the Boost.Test libraries are
> automatically found and linked (not with toolsets though which don't
> support auto-linking).
>
> So what's the difference between unit-test and test-suite? Anything
> recommended because the other is deprecated? And how do I refer to the
> Boost.Test libraries (all the other targets like /boost//filesystem
> work)?

You don't need test-suite.  The preferred way to write tests is

run mytest.cpp ;

In Christ,
Steven Watanabe

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Jamfiles for unit tests

by Boris Schaeling :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 15 Oct 2009 19:55:20 +0200, Steven Watanabe <watanabesj@...>  
wrote:

> [...]
>> ----------
>> import boost ;
>> import testing ;
>>
>> boost.use-project ;
>> project : requirements <library>/boost//test ;
>> unit-test mytest : mytest.cpp ;
>> ----------
>>
>> The linker (MSVC) complains it can't find the library (eg.  
>> libboost_test-vc90-mt-gd-1_39.lib). There seems to be something wrong  
>> with the target /boost//test (it exists but wrong files are looked up).
>
> Try adding <define>BOOST_ALL_NO_LIB to the project requirements.

It doesn't help. As far as I can tell it's not a problem with auto-linking  
really. If I add a few more references to other Boost libraries and run  
'bjam -n' I see that the linker is looking for these files (for example):

libboost_filesystem-vc90-mt-gd-1_39.lib
libboost_system-vc90-mt-gd-1_39.lib
libboost_thread-vc90-mt-gd-1_39.lib
libboost_test-vc90-mt-gd-1_39.lib

All the files exist except libboost_test-vc90-mt-gd-1_39.lib. The file is  
actually called libboost_unit_test_framework-vc90-mt-gd-1_39.lib. It  
doesn't matter either if I create debug or release versions or link  
statically or dynamically. Everytime a file boost_test... is looked up  
while it should be boost_unit_test_framework...

If I remove <library>/boost//test and add  
<linkflags>libboost_unit_test_framework-vc90-mt-gd-1_39.lib it all works  
again. But I would prefer a toolset-independent Jamfile.

This looks like a bug in the Jamfiles of Boost.Test to me. Can I overwrite  
the basename of a library in my Jamfile to make Boost.Build look up  
boost_unit_test_framework... and not boost_test...?

> [...]You don't need test-suite.  The preferred way to write tests is
>
> run mytest.cpp ;

Thanks, I'll forget unit-test and test-suite. :)

Boris

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Jamfiles for unit tests

by Steven Watanabe-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

AMDG

Boris Schaeling wrote:

> It doesn't help. As far as I can tell it's not a problem with
> auto-linking really. If I add a few more references to other Boost
> libraries and run 'bjam -n' I see that the linker is looking for these
> files (for example):
>
> libboost_filesystem-vc90-mt-gd-1_39.lib
> libboost_system-vc90-mt-gd-1_39.lib
> libboost_thread-vc90-mt-gd-1_39.lib
> libboost_test-vc90-mt-gd-1_39.lib
>
> All the files exist except libboost_test-vc90-mt-gd-1_39.lib. The file
> is actually called libboost_unit_test_framework-vc90-mt-gd-1_39.lib.
> It doesn't matter either if I create debug or release versions or link
> statically or dynamically. Everytime a file boost_test... is looked up
> while it should be boost_unit_test_framework...
>
> If I remove <library>/boost//test and add
> <linkflags>libboost_unit_test_framework-vc90-mt-gd-1_39.lib it all
> works again. But I would prefer a toolset-independent Jamfile.
>
> This looks like a bug in the Jamfiles of Boost.Test to me. Can I
> overwrite the basename of a library in my Jamfile to make Boost.Build
> look up boost_unit_test_framework... and not boost_test...?
I see.  This looks like a bug in the boost module.  Can you
apply the attached patch and use /boost//unit_test_framework?

In Christ,
Steven Watanabe


Index: tools/build/v2/contrib/boost.jam
===================================================================
--- tools/build/v2/contrib/boost.jam (revision 56813)
+++ tools/build/v2/contrib/boost.jam (working copy)
@@ -211,7 +211,7 @@
         <link>shared:<define>BOOST_GRAPH_DYN_LINK ;
     lib date_time        : : : :
         <link>shared:<define>BOOST_DATE_TIME_DYN_LINK ;
-    lib test             : : : :
+    lib unit_test_framework : : : :
         <link>shared:<define>BOOST_TEST_DYN_LINK  ;
     lib regex            : : : :
         <link>shared:<define>BOOST_REGEX_DYN_LINK  ;

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Jamfiles for unit tests

by Boris Schaeling :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 15 Oct 2009 21:07:35 +0200, Steven Watanabe <watanabesj@...>  
wrote:

> [...]
>> This looks like a bug in the Jamfiles of Boost.Test to me. Can I
>> overwrite the basename of a library in my Jamfile to make Boost.Build
>> look up boost_unit_test_framework... and not boost_test...?
>
> I see.  This looks like a bug in the boost module.  Can you
> apply the attached patch and use /boost//unit_test_framework?

Thanks, your patch works!

Boris

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Jamfiles for unit tests

by Steven Watanabe-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

AMDG

Boris Schaeling wrote:

> On Thu, 15 Oct 2009 21:07:35 +0200, Steven Watanabe
> <watanabesj@...> wrote:
>> [...]
>>> This looks like a bug in the Jamfiles of Boost.Test to me. Can I
>>> overwrite the basename of a library in my Jamfile to make Boost.Build
>>> look up boost_unit_test_framework... and not boost_test...?
>>
>> I see.  This looks like a bug in the boost module.  Can you
>> apply the attached patch and use /boost//unit_test_framework?
>
> Thanks, your patch works!

It looks like the boost module has some other issues too.
I'll try to do a bit of fixing up over the weekend.

In Christ,
Steven Watanabe

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Jamfiles for unit tests

by Anthony Foglia-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Steven Watanabe wrote:
> It looks like the boost module has some other issues too.
> I'll try to do a bit of fixing up over the weekend.


I made a bug report on this a few months ago.  Here's what I listed as
requiring an update:

* The unit test framework library should be unit_test_framework, not
test. (The library name, on linux at least, is boost_unit_test_framework.)

* The prg_exec_monitor library in Boost.Test should get its own target

* The 6 math libraries for C99 and TR1 in Boost.Math should get targets

https://svn.boost.org/trac/boost/ticket/3173

There might be more by now, but that's what I saw.

(I'd give a diff, but I have my own test changes in my copy as well.)

--
Anthony Foglia
Princeton Consultants
(609) 987-8787 x233

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

bjam - finding targets affected

by Anant Rao :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Using bjam, is there a way to find out which targets will be built?

Thanks,
Anant
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: bjam - finding targets affected

by Vladimir Prus-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Anant Rao wrote:

> Hi,
>
> Using bjam, is there a way to find out which targets will be built?

I think passing -n to bjam will have the desired effect.

BTW, please don't ask new questions by replying to an unrelated post. This breaks
threading and many email-processing workflows.

- Volodya


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build