Opened 8 years ago

Closed 7 years ago

#10317 closed Bugs (fixed)

boost::test corrupts contents of argv if a paramter contains whitespace

Reported by: Andrew Marshall <planetmarshalluk@…> Owned by: Raffi Enficiaud
Milestone: Boost 1.60.0 Component: test
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

command line arguments containing spaces are corrupted by the test framework's internal command line parser. This is a problem if passing additional arguments to the test executable containing, for example, paths with spaces.

Compile and run the following with the argument "root
foo bar
file.txt"

#include <string>
#include <boost/test/unit_test.hpp>

using namespace boost::test;

void command_line_parser_preserves_whitespace(const std::string & after) {
// this will fail as after = "root\\foo"
  BOOST_REQUIRE_EQUAL(std::string("root\\foo bar\\file.txt", after);
}

bool init_function() {
     framework::master_test_suite().
        add( BOOST_TEST_CASE( boost::bind( &command_line_parser_preserves_whitespace, std::string path(framework::master_test_suite.path().argv[1]) ) ) )
    return true;
}

int main( int argc, char* argv[] ) {
    return ::boost::unit_test::unit_test_main( &init_function, argc, argv );
}

Change History (5)

comment:1 by Gennadiy Rozental, 7 years ago

Milestone: To Be DeterminedBoost 1.60.0
Resolution: fixed
Status: newclosed

This is addressed in trunk and is going to be released with next version of Boost

comment:2 by Raffi Enficiaud, 7 years ago

Resolution: fixed
Status: closedreopened

reopening for keeping track of the change

comment:3 by Raffi Enficiaud, 7 years ago

Owner: changed from Gennadiy Rozental to Raffi Enficiaud
Status: reopenednew

comment:4 by Raffi Enficiaud, 7 years ago

Status: newassigned

comment:5 by Raffi Enficiaud, 7 years ago

Resolution: fixed
Status: assignedclosed

merged to master

Note: See TracTickets for help on using tickets.