[test]redefinition of boost::unit_test::ut_detail::auto_test_unit_registrar
Hello,
I'm using Boost.Test.
When I define BOOST_AUTO_TEST_SUITE, I got a compile error
'redefinition of
boost::unit_test::ut_detail::auto_test_unit_registrar' if the all
following conditions are satisfied:
1. The test suite names are the same.
2. BOOST_AUTO_TEST_SUITE are defined in different files.
3. The files are included by one file.
4. BOOST_AUTO_TEST_SUITE are defined at the same line number.
For example,
main.cpp
#define BOOST_TEST_MODULE test
#include
Le 13/02/2017 à 15:39, Takatoshi Kondo via Boost a écrit :
Hello,
I'm using Boost.Test.
When I define BOOST_AUTO_TEST_SUITE, I got a compile error 'redefinition of boost::unit_test::ut_detail::auto_test_unit_registrar' if the all following conditions are satisfied:
1. The test suite names are the same. 2. BOOST_AUTO_TEST_SUITE are defined in different files. 3. The files are included by one file. 4. BOOST_AUTO_TEST_SUITE are defined at the same line number.
For example,
main.cpp
#define BOOST_TEST_MODULE test #include
#include "one.ipp" #include "two.ipp"
one.ipp
BOOST_AUTO_TEST_SUITE(a) BOOST_AUTO_TEST_CASE(tc1) { } BOOST_AUTO_TEST_SUITE_END()
two.ipp
BOOST_AUTO_TEST_SUITE(a) BOOST_AUTO_TEST_CASE(tc2) { } BOOST_AUTO_TEST_SUITE_END()
Here is a live demo: http://melpon.org/wandbox/permlink/R459VQ6apnQfapyw
If I insert a line the top of two.ipp, no errors are occurred.
http://melpon.org/wandbox/permlink/jPRTstNDVb7agjXl
According to the following document http://www.boost.org/doc/libs/1_63_0/libs/test/doc/html/boost_test/tests_org...
"The same test suite can be restarted multiple times inside the same test file or in a different test files."
The compile error is caused by the following line: https://github.com/boostorg/test/blob/develop/include/boost/test/unit_test_s...
If I replace BOOST_JOIN( BOOST_JOIN( test_name, _registrar ), __LINE__ ) \ with BOOST_JOIN( BOOST_JOIN( test_name, _registrar ), __COUNTER__ ) \ , then the error is disappeared.
However, __COUNTER__ is not portable.
I know that I can compile one.ipp and two.ipp separately, but I also want to have the option that include them from one file.
Is there any good way to solve the error?
Thanks, Takatoshi Kondo
Hi, Please have a look here: https://svn.boost.org/trac/boost/ticket/12712 Thanks, Raffi
Thank you Raffi,
Please have a look here: https://svn.boost.org/trac/boost/ticket/12712
That is exactly I expect solution. I look forward to releasse 1.64.0. Thanks, Takatoshi Kondo
participants (2)
-
Raffi Enficiaud
-
Takatoshi Kondo