Subject: Re: [boost] [test] unit test command-line handling
From: Raffi Enficiaud (raffi.enficiaud_at_[hidden])
Date: 2018-09-13 18:53:40
On 13.09.18 00:50, Stefan Seefeld via Boost wrote:
> On 09/12/18 14:28, Raffi Enficiaud wrote:
>> On 12.09.18 00:21, Stefan Seefeld via Boost wrote:
>>> * What (non-deprecated) API can I use to access command-line arguments
>>> during test initialization ?
>> By "test initialization", do you mean before the first test starts?
>> The argc/argv are available to the master test suite:
> I see. That code could use a bit of an explanation. You present a
> function that takes "argc" and "argv" as input, but rather than using
> those variables themselves, you access the argument vector via
> "framework::master_test_suite().argc" etc.. I find that a bit...em...
> counter-intuitive. What's the rationale for that ? Is the function
> argument the full argument vector, including the ones already consumed
> by Boost.Test itself ?
Apart from the historical side of this design, this has two benefits IMO:
1- the argc/argv passed to the rest of the test module at runtime may
have been altered, either by the test module itself (dropping some
params in a global fixture), or by the boost.test framework. The
argc/argv seen by the test module are the ones that appear after the --
2- the master test suite is a singleton, so you do not need to pass
>> In 1.68, it is also possible to use this for data driven test cases,
>> using the make_delayed (if you need a test generator that is dependent
>> on your argc/argv).
>>> * How does my own handling of command-line arguments interact with
>>> Boost.Test's own command-line argument handling ?
>> I am surprised I did not create a doc entry about this. The way it
>> works is indicated in the change logs of boost.test:
>> Anything after -- is passed to the master test suite argc/argv and is
>> available to your test module.
> That makes sense.
>> I will update the doc on the two points above to make it clearer.
> Thank you. Please consider adding a top-level section on passing
> command-line arguments, perhaps under "Runtime parameters". I believe
> that's a common enough use-case that it might be worthwhile for this not
> to be hidden in a (seemingly unrelated) section about the master test suite.
Yes, will do, I regularly have questions about this part.
> Thanks for your help !
You're very welcome.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk