Boost logo

Boost-Build :

Subject: Re: [Boost-build] How to create a run-fail for own binary
From: Vladimir Prus (ghost_at_[hidden])
Date: 2009-02-18 05:19:57


On Wednesday 18 February 2009 12:43:02 Sven Van Echelpoel wrote:
> Hi,
>
> we already managed successfully to run tests with a binary created by
> another target, as per
> http://www.nabble.com/Running-tests-with-executable-built-by-another-target-to21727535.html.
>
> What we want to do now is to run tests and they can succeed or fail. For
> that I have created two rules:
>
> rule my-run (
> target : source : options *
> )
> {
> make $(target) : $(source) : @DoMyRun : $(options) ;
> }
>
> rule my-run-fail (
> target : source : options *
> )
> {
> # This target is expected to fail to build. Then it's actually OK
> FAIL_EXPECTED $(target) ;
>
> make $(target) : $(source) : @DoMyRun : $(options) ;
> }
>
> I would have assumed that simply adding the line "FAIL_EXPECTED
> $(target) ;" would turn a failed run into a successful one and vice
> versa. Alas this turns out not to be the case. If the run fails
> (expected), the target fails.

FAIL_EXPECTED is Boost.Jam builtin, and takes a Boost.Jam target. The rules above
operate on Boost.Build metatagets, so FAIL_EXPECTED won't do much. And even if it
worked, I am not sure you will 100% like the result -- it would mean that
if the targets fails to be created, Boost.Build will not complain. But it will
not create anything either. Consequently, next time you build, you'll try to
build the same target again.

Assuming you want something to be created, you probably can do something like the
Jamroot I have attached. It will cause $(target).test file to be created if
the primary rules fails.

Let me know if this works for you.

- Volodya




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