Просмотр исходного кода

reliability fixes from Jens

[SVN r19031]
Beman Dawes 23 лет назад
Родитель
Сommit
675c74ef9c
2 измененных файлов с 61 добавлено и 46 удалено
  1. 14 6
      tools/regression/detail/tiny_xml.cpp
  2. 47 40
      tools/regression/process_jam_log.cpp

+ 14 - 6
tools/regression/detail/tiny_xml.cpp

@@ -28,7 +28,8 @@ namespace
       != 0 )
     {
       result += c;
-      in.get( c );
+      if(!in.get( c ))
+        throw std::string("xml: unexpected eof");
     }
     return result;
   }
@@ -69,8 +70,11 @@ namespace boost
       char c = 0;  // current character
       element_ptr e( new element );
 
-      in.get( c );
-      if ( c == '<' ) in.get( c );
+      if(!in.get( c ))
+        throw std::string("xml: unexpected eof");
+      if ( c == '<' )
+        if(!in.get( c ))
+          throw std::string("xml: unexpected eof");
 
       e->name = get_name( c, in );
       eat_whitespace( c, in );
@@ -89,7 +93,9 @@ namespace boost
         e->attributes.push_back( a );
         eat_whitespace( c, in );
       }
-      in.get( c ); // next after '>'
+      if(!in.get( c )) // next after '>'
+        throw std::string("xml: unexpected eof");
+
       eat_whitespace( c, in );
 
       // sub-elements
@@ -108,12 +114,14 @@ namespace boost
         while ( c != '<' )
         {
           e->content += c;
-          in.get( c );
+          if(!in.get( c ))
+            throw std::string("xml: unexpected eof");
         }
       }
 
       assert( c == '<' );
-      in.get( c ); // next after '<'
+      if(!in.get( c )) // next after '<'
+        throw std::string("xml: unexpected eof");
 
       eat_delim( c, in, '/', msg );
       std::string end_name( get_name( c, in ) );

+ 47 - 40
tools/regression/process_jam_log.cpp

@@ -167,50 +167,56 @@ namespace
     {
       fs::path pth( locate_root / target_directory / "test_log.xml" );
       fs::ifstream file( pth  );
-      if ( !file )
+      if ( file )   // existing file
       {
-        test_info info;
-        string library_name;
-        test2info_map::iterator itr( test2info.find( test_name ) );
-        if ( itr != test2info.end() )
+        try
         {
-          info = itr->second;
-          string::size_type start_pos( info.file_path.find( "libs/" ) );
-          if ( start_pos != string::npos )
-          {
-            start_pos += 5;
-            string::size_type end_pos( info.file_path.find( '/', start_pos ) );
-            library_name = info.file_path.substr( start_pos,
-              end_pos - start_pos );
-
-            if ( fs::exists( boost_root / "libs" / library_name / "sublibs" ) )
-            {
-              library_name += info.file_path.substr( end_pos,
-                info.file_path.find( '/', end_pos+1 ) - end_pos );
-            }
-          }
+          m_root = xml::parse( file, pth.string() );
+          return;
+        }
+        catch(...)
+        {
+          // unable to parse existing XML file, fall through
         }
-        m_root.reset( new xml::element( "test-log" ) );
-        m_root->attributes.push_back(
-          xml::attribute( "library", library_name ) );
-        m_root->attributes.push_back(
-          xml::attribute( "test-name", test_name ) );
-        m_root->attributes.push_back(
-          xml::attribute( "test-type", info.type ) );
-        m_root->attributes.push_back(
-          xml::attribute( "test-program", info.file_path ) );
-        m_root->attributes.push_back(
-          xml::attribute( "target-directory", target_directory ) );
-        m_root->attributes.push_back(
-          xml::attribute( "toolset", toolset ) );
-        m_root->attributes.push_back(
-          xml::attribute( "show-run-output",
-            info.always_show_run_output ? "true" : "false" ) );
       }
-      else // existing file
+
+      test_info info;
+      string library_name;
+      test2info_map::iterator itr( test2info.find( test_name ) );
+      if ( itr != test2info.end() )
       {
-        m_root = xml::parse( file, pth.string() );
+        info = itr->second;
+        string::size_type start_pos( info.file_path.find( "libs/" ) );
+        if ( start_pos != string::npos )
+        {
+          start_pos += 5;
+          string::size_type end_pos( info.file_path.find( '/', start_pos ) );
+          library_name = info.file_path.substr( start_pos,
+            end_pos - start_pos );
+
+          if ( fs::exists( boost_root / "libs" / library_name / "sublibs" ) )
+          {
+            library_name += info.file_path.substr( end_pos,
+              info.file_path.find( '/', end_pos+1 ) - end_pos );
+          }
+        }
       }
+      m_root.reset( new xml::element( "test-log" ) );
+      m_root->attributes.push_back(
+        xml::attribute( "library", library_name ) );
+      m_root->attributes.push_back(
+        xml::attribute( "test-name", test_name ) );
+      m_root->attributes.push_back(
+        xml::attribute( "test-type", info.type ) );
+      m_root->attributes.push_back(
+        xml::attribute( "test-program", info.file_path ) );
+      m_root->attributes.push_back(
+        xml::attribute( "target-directory", target_directory ) );
+      m_root->attributes.push_back(
+        xml::attribute( "toolset", toolset ) );
+      m_root->attributes.push_back(
+        xml::attribute( "show-run-output",
+          info.always_show_run_output ? "true" : "false" ) );
     }
 
     ~test_log()
@@ -399,7 +405,7 @@ int cpp_main( int argc, char ** argv )
 
   while ( std::getline( std::cin, line ) )
   {
-//      std::cout << line << "\n";
+    //    std::cout << line << "\n";
 
     // create map of test-name to test-info
     if ( line.find( "boost-test(" ) == 0 )
@@ -495,7 +501,8 @@ int cpp_main( int argc, char ** argv )
       content.clear();
       capture_lines = false;
 
-      if ( line.find( ".exe for lack of " ) != string::npos )
+      if ( line.find( " for lack of " ) != string::npos
+        && line.find( ".run for lack of " ) == string::npos )
       {
         capture_lines = true;
 

粤ICP备19079148号