Opened 9 years ago
Closed 7 years ago
#8559 closed Bugs (fixed)
Impossible to run single test case if name contains whitespace
Reported by: | Owned by: | Gennadiy Rozental | |
---|---|---|---|
Milestone: | Boost 1.59.0 | Component: | test |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | Cc: |
Description
When using boost test with template based test cases it is possible that name create will contain whitespace (all const arguments, rest up to typeid(T).name). For such a name it is impossible to run test case due to bug in library related to parsing of command line arguments assuming ' ' as a separator and cutting name of test case in place of space, even if properly enclosed in quotes in command line.
Simple workaround would be to replace all space characters in name of test case with different one ('_'?). Resolution of https://svn.boost.org/trac/boost/ticket/3384 would also solve that problem as well.
kamilwitecki@laney:~/projects/c++/boosts_test_bug$ cat main.cpp
#define BOOST_TEST_MAIN 1 #include <boost/test/included/unit_test.hpp> #include <boost/test/test_case_template.hpp> #include <boost/mpl/list.hpp> typedef boost::mpl::list<int, const int> test_types; BOOST_AUTO_TEST_CASE_TEMPLATE( my_test, T, test_types ) { BOOST_CHECK_EQUAL( sizeof(T), (unsigned)0 ); }
kamilwitecki@laney:~/projects/c++/boosts_test_bug$ g++ main.cpp -lboost_unit_test_framework && ./a.out
Running 2 test cases... main.cpp(11): error in "my_test<i>": check sizeof(T) == (unsigned)0 failed [4 != 0] main.cpp(11): error in "my_test<i const>": check sizeof(T) == (unsigned)0 failed [4 != 0] *** 2 failures detected in test suite "Master Test Suite"
kamilwitecki@laney:~/projects/c++/boosts_test_bug$ ./a.out -t "my_test<i>"
Running 1 test case... main.cpp(11): error in "my_test<i>": check sizeof(T) == (unsigned)0 failed [4 != 0] *** 1 failure detected in test suite "Master Test Suite"
kamilwitecki@laney:~/projects/c++/boosts_test_bug$ ./a.out -t "my_test<i const>"
Test setup error: no test cases matching filter kamilwitecki@laney:~/projects/c++/boosts_test_bug$
Attachments (1)
Change History (4)
by , 9 years ago
Attachment: | boost_test.patch added |
---|
follow-up: 2 comment:1 by , 9 years ago
It appears that not only spaces, but also commas cause the same problem, since they appear in std::string typeid(T).name. Patch should be complemented with:
std::replace(full_name.begin(), full_name.end(), boost::is_any_of(" ,"), '_');
comment:2 by , 9 years ago
Replying to hanna@…:
It appears that not only spaces, but also commas cause the same problem, since they appear in std::string typeid(T).name. Patch should be complemented with:
std::replace(full_name.begin(), full_name.end(), boost::is_any_of(" ,"), '_');
Of course, not std::replace(...)
but:
std::replace_if(...)
in this case should be used.
comment:3 by , 7 years ago
Milestone: | To Be Determined → Boost 1.59.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Eliminated spaces in test case names
Simple patch replacing ' ' with '_' in test case name.