Opened 14 years ago

Closed 14 years ago

#2395 closed Patches (fixed)

[filesystem] operations_test regression test fails on MSVC with STDCXX

Reported by: Farid Zaripov <faridz@…> Owned by: Beman Dawes
Milestone: Boost 1.37.0 Component: filesystem
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

The operations_test regression test fails on MSVC with STDCXX: http://tinyurl.com/53m6t4

The reason is checking in libs/filesystem/test/operation_test.cpp, lines 149-150 :

    try
    {
      fs::create_directory( "no-such-dir/foo/bar" );
    }
    catch ( std::runtime_error x )
    {
      exception_thrown = true;
      if ( report_throws ) std::cout << x.what() << std::endl;
      if ( platform == "Windows" && language_id == 0x0409 ) // English (United States)
        BOOST_CHECK( std::strcmp( x.what(),
          "boost::filesystem::create_directory" ) == 0 );
    }

Our implementation of the copy ctor (as well as assignment operator) of the std::runtime_error class

copying the resulting string of the what() method of the operand.

So that in the following code the all three assertions will pass:

  boost::system::system_error se(3, boost::system::get_system_category(),
                                                 "boost::filesystem::create_directory");
  std::runtime_error re = se;
  assert (0 != std::strcmp (re.what(), "boost::filesystem::create_directory"));
  assert (0 == std::strcmp (re.what(), se.what()));
  assert (0 == std::strcmp (re.what(), "boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir\\foo\\bar\""));

The proposed patch:

Index: libs/filesystem/test/operations_test.cpp
===================================================================
--- libs/filesystem/test/operations_test.cpp	(revision 49179)
+++ libs/filesystem/test/operations_test.cpp	(working copy)
@@ -146,8 +146,9 @@
       exception_thrown = true;
       if ( report_throws ) std::cout << x.what() << std::endl;
       if ( platform == "Windows" && language_id == 0x0409 ) // English (United States)
-        BOOST_CHECK( std::strcmp( x.what(),
-          "boost::filesystem::create_directory" ) == 0 );
+        BOOST_CHECK( std::strncmp( x.what(),
+          "boost::filesystem::create_directory",
+          sizeof("boost::filesystem::create_directory")-1 ) == 0 );
     }
     BOOST_CHECK( exception_thrown );
 

Change History (1)

comment:1 by Beman Dawes, 14 years ago

Resolution: fixed
Status: newclosed

Thanks!

--Beman

Note: See TracTickets for help on using tickets.