Boost logo

Boost-Build :

Subject: Re: [Boost-build] Conditional unit test execution
From: A. Schamp (schamp_at_[hidden])
Date: 2014-02-04 13:40:06


Volodya,

Thank you for such specific help. I think I understand the concept of the
generator and the meta-targets a little bit better. I don't quite see
whether I can integrate that with the 'run' and 'link' rules provided by
the testing.jam package, which has features (re-running tests if targets
change, etc.) that we'd like to retain. Is such a thing possible, or would
we have to roll our own in some way?

We are using <target-os>linux in both cases, but I presume another property
(architecture or toolset) could be accessible in a similar way?

Thank you very much,
Andrew

On Tue, Feb 4, 2014 at 9:18 AM, Vladimir Prus <ghost_at_[hidden]> wrote:

> On 04.02.2014 17:07, A. Schamp wrote:
>
>> We are using Boost.Build to build our software for two platforms, Linux
>> x86 (32-bit) and PPC (32-bit). We have a cross compiler set up for
>> our PPC build, and so run both builds on our x86 platform using different
>> toolset= declarations. Additionally, for our PPC build, we specify
>> architecture=power.
>>
>> This works great for building our software, but we also have a suite of
>> unit tests that are part of our main target, which we want to
>> execute automatically on native platforms.
>>
>> We have some wrappers set up, they look like this (but they don't quite
>> work):
>>
>> feature.feature test-output : user report : incidental optional ;
>>
>> # a helper rule to wrap the build stuff common to all boost.test
>> test cases
>> rule run-test ( target : source : requirements * : properties * )
>> {
>> if <toolset>gcc-ppc
>> {
>> link $(source) boost_unit_test_framework $(requirements) :
>> <define>BOOST_TEST_NO_MAIN <define>BOOST_TEST_MODULE=$(source:B) :
>> $(target) ;
>> }
>> else
>> {
>> run $(source) boost_unit_test_framework $(requirements) :
>> $(properties) : : <define>BOOST_TEST_NO_MAIN
>> <define>BOOST_TEST_MODULE=$(source:B) : $(target) : ;
>> }
>> }
>>
>
> Hi Andrew,
>
> I am attaching a example, somewhat simplified from what you have, that
> should do the trick. When I run it with
>
> b2 toolset=gcc target-os=linux
>
> the test is linked and run. When I do
>
> b2 toolset=gcc target-os=window
>
> It is just linked.
>
> Let me explain what I did. Both the 'link' and 'run' functions create
> metatargets, which are then generated with specific
> properties to create targets. When Jamfiles are read, and metatargets are
> created by run-test rule above, we don't know
> what properties will be used to generate them, so that condition above
> won't work. We need to have conditional code
> executed as part of generating targets from a metatarget.
>
> I did that by creating new target type, and creating a generator for that
> type which recurses using either RUN or EXE
> type. I've used the example/generator as base for this experiment.
>
> Let me know if this helps?
>
> - Volodya
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost-build
>
>



Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk