Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost.test] parsing runtime arguments
From: Raffi Enficiaud (raffi.enficiaud_at_[hidden])
Date: 2018-08-24 13:50:05


On 12.08.18 20:17, Olaf Peter via Boost-users wrote:
> Hi,
> how get an 'user' API for the boost.test like this:
>
> testsuite_xyz -- --help
>
> or even
>
> testsuite_xyz -- --save-path=/foo
>
> to get the user aspects. I know I can get the args by
>
>     int argc{ framework::master_test_suite().argc };
>     char** argv{ framework::master_test_suite().argv };
>
> Further, at test/include/boost/test/utils/runtime/cla/parser.hpp are
> some utils used by boost.test self. Anyway, the problem rises to get the
> behaviour desribed above, simply using a global fixture with:
>
> fixture::fixture()
> {
>     int argc{ utf::framework::master_test_suite().argc };
>     char** argv{ utf::framework::master_test_suite().argv };
>
>        for (int i = 0; i != argc; ++i) {
>            std::cerr << "test_observer_fixture: " << argv[i] << "\n";
>        }
> }
>
> doesn't give the expected results - all the BOOST_AUTO_TEST_SUITE test
> cases are called even they depend on this arguments.
>
> Thanks,
> Olaf

What about using the new API for fixtures and accessing argc/argv from
the "setup" member function?

https://www.boost.org/doc/libs/1_68_0/libs/test/doc/html/boost_test/tests_organization/fixtures/models.html

If you are constructing a global fixture, the class is instanciated
before the framework starts, hence the observed behaviour.

Best,
Raffi


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net