Rafał Rawicki
Rafał Rawicki

Reputation: 22700

Disabling unit-test compilation in Boost.Build

Boost.Build documentation is quite laconic when it comes to testing.

All tests in my project are defined using unit-test rule.

The only property mentioned, by the documentation, is testing.launcher, but that can only disable tests' execution when set to testing.launcher=true.

How to completely disable compilation of unit-test rules? I would like to do that temporarily, for example, by setting a property from commandline. I could not find any information how to do that or any reference documentation for other testing.* properties.

Upvotes: 1

Views: 1210

Answers (3)

Vicente Botet Escriba
Vicente Botet Escriba

Reputation: 4355

I use explicit test suites for this purpose as in

explicit X ;
test-suite X
:
      [ run test1.cpp ]
      [ run test2.cpp ]
      [ run test3.cpp ]
      [ run test4.cpp ]
;

You will need to request explicitly the execution of the tests in the test-suite X using

bjam X

Upvotes: 0

Rafał Rawicki
Rafał Rawicki

Reputation: 22700

As I read most of the Boost.Build documentation and the relevant part of its code I found no way to temporary disable building specific rule or the set of targets (for example by matching tests' targets with a regular expression).

It is, also, worth noting, that unit-test was deprecated in favor of the new testing rules: run, run-fail, compile, compile-fail, link, link-fail.

Now, probably, I'm going to create my own rule, as in @GrafikRobot's answer, but instead of making the target explicit I will make the rule empty in the presence of a certain feature.

Upvotes: 1

GrafikRobot
GrafikRobot

Reputation: 3059

If you mean disabling them by default? You can do it by adding "explicit ;" for each unit test. If you have many such targets you can save some typing and declare a rule that does it for you, plus declaring the unit test like:

rule explicit-unit-test ( target : source : properties * )
{
    unit-test $(target) : $(source) : $(properties) ;
    explicit $(target) ;
}

If you want something else.. I guess you need to better explain your question because I can't think of what else you could want.

Upvotes: 2

Related Questions