Kaynağa Gözat

test-type now in --dump-tests output + now work with subincludes

[SVN r16773]
Beman Dawes 23 yıl önce
ebeveyn
işleme
cd681cb98a

+ 51 - 81
tools/regression/compiler_status.cpp

@@ -10,9 +10,9 @@
 
 
     This program was designed to work unchanged on all platforms and
     This program was designed to work unchanged on all platforms and
     configurations.  All output which is platform or configuration dependent
     configurations.  All output which is platform or configuration dependent
-    is obtained from external sources such as the Jamfile, the residue
-    from jam execution, the tools/build/xxx-tools.jam files, or the output
-    of the config_info tests.
+    is obtained from external sources such as the .xml file from
+    process_jam_log execution, the tools/build/xxx-tools.jam files, or the
+    output of the config_info tests.
 
 
     Please avoid adding platform or configuration dependencies during
     Please avoid adding platform or configuration dependencies during
     program maintenance.
     program maintenance.
@@ -62,7 +62,6 @@ namespace
   std::vector<string> toolsets;
   std::vector<string> toolsets;
 
 
   fs::ifstream jamfile;
   fs::ifstream jamfile;
-  fs::ifstream testsuitesfile; // in addition to jamfile
   fs::ofstream report;
   fs::ofstream report;
   fs::ofstream links_file;
   fs::ofstream links_file;
   string links_name;
   string links_name;
@@ -196,61 +195,6 @@ namespace
     return result;
     return result;
   }
   }
 
 
-//  test_type_desc  ----------------------------------------------------------//
-//  from jamfile or testsuitesfile
-
-  string test_type_desc( const string & test_name, fs::ifstream & file)
-  {
-    // adding "/" and ".c" eliminates a couple of corner cases.
-    // ".c" rather than ".cpp" because regex library includes some .c tests
-    string search_name1( "/" + test_name + ".c" );
-    string search_name2( " " + test_name + " " );
-
-    string result;
-    if ( file.is_open() )
-    {
-      file.clear();
-      file.seekg(0);
-      string line;
-      while( std::getline( file, line ) )
-      {
-        if ( line.find( ".c" ) != string::npos )
-        {
-          if ( line.find( "run " ) != string::npos )
-            result = "run";
-          else if ( line.find( "run-fail " ) != string::npos )
-            result = "run-fail";
-          else if ( line.find( "link " ) != string::npos )
-            result = "link";
-          else if ( line.find( "link-fail " ) != string::npos )
-            result = "link-fail";
-          else if ( line.find( "compile " ) != string::npos )
-            result = "compile";
-          else if ( line.find( "compile-fail " ) != string::npos )
-            result = "compile-fail";
-        }
-        if ( result.size() &&
-          ( line.find( search_name1 ) != string::npos
-          || line.find( search_name2 ) != string::npos ) )
-        {
-          if ( line.find( "# compiler_status<always_show_run_output>" )
-            != string::npos ) result.insert( (std::string::size_type)0, (std::string::size_type)1, '*' );
-          return result;
-        }
-      }
-      result.clear();
-    }
-    return result;
-  }
-
-  string test_type_desc( const string & test_name )
-  {
-    string result = test_type_desc( test_name, jamfile );
-    if ( result.empty() )
-      result = test_type_desc( test_name, testsuitesfile );
-    return result;
-  }
-
 //  target_directory  --------------------------------------------------------//
 //  target_directory  --------------------------------------------------------//
 //  this amounts to a request to find a unique leaf directory
 //  this amounts to a request to find a unique leaf directory
 
 
@@ -448,9 +392,11 @@ const string & attribute_value( const xml::element_ptr & element,
     const string & test_name, // "any_test"
     const string & test_name, // "any_test"
     string & target )
     string & target )
   {
   {
-    // get the library name and test program path from the .xml file
+    // get library name, test-type, test-program path, etc., from the .xml file
     string lib_name;
     string lib_name;
     string test_path( test_name ); // test_name is default if missing .test
     string test_path( test_name ); // test_name is default if missing .test
+    string test_type( "unknown" );
+    bool always_show_run_output( false );
     fs::path xml_file_path;
     fs::path xml_file_path;
     if ( find_file( test_dir, "test_log.xml", xml_file_path ) )
     if ( find_file( test_dir, "test_log.xml", xml_file_path ) )
     {
     {
@@ -460,6 +406,9 @@ const string & attribute_value( const xml::element_ptr & element,
         xml::element_ptr db = xml::parse( file, xml_file_path.string() );
         xml::element_ptr db = xml::parse( file, xml_file_path.string() );
         test_path = attribute_value( db, "test-program" );
         test_path = attribute_value( db, "test-program" );
         lib_name = attribute_value( db, "library" );
         lib_name = attribute_value( db, "library" );
+        test_type = attribute_value( db, "test-type" );
+        always_show_run_output
+          = attribute_value( db, "show-run-output" ) == "true";
       }
       }
     }
     }
 
 
@@ -470,11 +419,6 @@ const string & attribute_value( const xml::element_ptr & element,
     string::size_type row_start_pos = target.size();
     string::size_type row_start_pos = target.size();
     target += "<tr><td><a href=\"" + lib_docs_path + "\">"  + lib_name  + "</a></td>";
     target += "<tr><td><a href=\"" + lib_docs_path + "\">"  + lib_name  + "</a></td>";
     target += "<td><a href=\"" + test_path + "\">" + test_name + "</a></td>";
     target += "<td><a href=\"" + test_path + "\">" + test_name + "</a></td>";
-
-    string test_type = test_type_desc( test_name );
-    bool always_show_run_output = false;
-    if ( !test_type.empty() && test_type[0] == '*' )
-      { always_show_run_output = true; test_type.erase( 0, 1 ); }
     target += "<td>" + test_type + "</td>";
     target += "<td>" + test_type + "</td>";
 
 
     bool no_warn_save = no_warn;
     bool no_warn_save = no_warn;
@@ -494,27 +438,55 @@ const string & attribute_value( const xml::element_ptr & element,
     no_warn = no_warn_save;
     no_warn = no_warn_save;
   }
   }
 
 
+//  do_rows_for_sub_tree  ----------------------------------------------------//
+
+  void do_rows_for_sub_tree( const fs::path & boost_root_dir,
+    const fs::path & bin_dir, std::vector<string> & results )
+  {
+    for ( fs::directory_iterator itr( bin_dir ); itr != end_itr; ++itr )
+    {
+      if ( fs::is_directory( *itr ) )
+      {
+        results.push_back( std::string() ); 
+        do_row( boost_root_dir, *itr,
+                itr->leaf().substr( 0, itr->leaf().size()-5 ),
+                results[results.size()-1] );
+      }
+    }
+  }
+
 //  do_table_body  -----------------------------------------------------------//
 //  do_table_body  -----------------------------------------------------------//
 
 
   void do_table_body(
   void do_table_body(
-    const fs::path & boost_root_dir, const fs::path & build_dir )
+    const fs::path & boost_root_dir, const fs::path & bin_dir )
   {
   {
     // rows are held in a vector so they can be sorted, if desired.
     // rows are held in a vector so they can be sorted, if desired.
     std::vector<string> results;
     std::vector<string> results;
 
 
-    // each test directory
-    for ( fs::directory_iterator itr( build_dir ); itr != end_itr; ++itr )
+    // do primary bin directory
+    do_rows_for_sub_tree( boost_root_dir, bin_dir, results );
+
+    // do subinclude bin directories
+    jamfile.clear();
+    jamfile.seekg(0);
+    string line;
+    while( std::getline( jamfile, line ) )
     {
     {
-      if ( fs::is_directory( *itr ) )
+      string::size_type pos( line.find( "subinclude" ) );
+      if ( pos != string::npos
+        && line.find( '#' ) > pos )
       {
       {
-        results.push_back( std::string() ); // no sort required, but leave code
-                                            // in place in case that changes
-        do_row( boost_root_dir, *itr,
-                itr->leaf().substr( 0, itr->leaf().size()-5 ),
-                results[results.size()-1] );
+        pos = line.find_first_not_of( " \t", pos+10 );
+        if ( pos == string::npos ) continue;
+        string subinclude_bin_dir(
+          line.substr( pos, line.find_first_of( " \t", pos )-pos ) );
+//        std::cout << "subinclude: " << subinclude_bin_dir << '\n';
+        do_rows_for_sub_tree( boost_root_dir,
+          boost_root_dir / subinclude_bin_dir / "/bin", results );  
       }
       }
     }
     }
 
 
+
     std::sort( results.begin(), results.end() );
     std::sort( results.begin(), results.end() );
 
 
     for ( std::vector<string>::iterator v(results.begin());
     for ( std::vector<string>::iterator v(results.begin());
@@ -526,8 +498,8 @@ const string & attribute_value( const xml::element_ptr & element,
 
 
   void do_table( const fs::path & boost_root_dir )
   void do_table( const fs::path & boost_root_dir )
   {
   {
-//    fs::path build_dir( boost_root_dir / "status" / "bin" );
-    fs::path build_dir( fs::initial_path() / "bin" );
+//    fs::path bin_dir( boost_root_dir / "status" / "bin" );
+    fs::path bin_dir( fs::initial_path() / "bin" );
 
 
     report << "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n";
     report << "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n";
 
 
@@ -536,7 +508,7 @@ const string & attribute_value( const xml::element_ptr & element,
     report << "<tr><td>Library</td><td>Test Name</td>\n"
     report << "<tr><td>Library</td><td>Test Name</td>\n"
       "<td><a href=\"compiler_status.html#test-type\">Test Type</a></td>\n";
       "<td><a href=\"compiler_status.html#test-type\">Test Type</a></td>\n";
 
 
-    fs::directory_iterator itr( build_dir );
+    fs::directory_iterator itr( bin_dir );
     while ( itr != end_itr && !fs::is_directory( *itr ) ) ++itr; // bypass chaff
     while ( itr != end_itr && !fs::is_directory( *itr ) ) ++itr; // bypass chaff
     if ( itr != end_itr )
     if ( itr != end_itr )
     {
     {
@@ -567,7 +539,7 @@ const string & attribute_value( const xml::element_ptr & element,
 
 
     // now the rest of the table body
     // now the rest of the table body
 
 
-    do_table_body( boost_root_dir, build_dir );
+    do_table_body( boost_root_dir, bin_dir );
 
 
     report << "</table>\n";
     report << "</table>\n";
   }
   }
@@ -605,6 +577,7 @@ int cpp_main( int argc, char * argv[] ) // note name!
   }
   }
 
 
   boost_root_dir = fs::path( argv[1], fs::native );
   boost_root_dir = fs::path( argv[1], fs::native );
+
   fs::path jamfile_path( fs::initial_path() / "Jamfile" );
   fs::path jamfile_path( fs::initial_path() / "Jamfile" );
   jamfile.open( jamfile_path );
   jamfile.open( jamfile_path );
   if ( !jamfile )
   if ( !jamfile )
@@ -613,9 +586,6 @@ int cpp_main( int argc, char * argv[] ) // note name!
     return 1;
     return 1;
   }
   }
 
 
-  fs::path testsuitesfile_path( fs::initial_path() / "testsuites.jam" );
-  testsuitesfile.open( testsuitesfile_path );
-
   report.open( argv[2] );
   report.open( argv[2] );
   if ( !report )
   if ( !report )
   {
   {

+ 40 - 24
tools/regression/process_jam_log.cpp

@@ -16,6 +16,7 @@
 #include <map>
 #include <map>
 #include <utility> // for make_pair
 #include <utility> // for make_pair
 #include <ctime>
 #include <ctime>
+#include <cctype>   // for tolower
 
 
 using std::string;
 using std::string;
 namespace xml = boost::tiny_xml;
 namespace xml = boost::tiny_xml;
@@ -26,8 +27,14 @@ namespace fs = boost::filesystem;
 
 
 namespace
 namespace
 {
 {
-  typedef std::map< string, string > test2prog_map;  // test_name, test_file_path
-  test2prog_map test2prog;
+  struct test_info
+  {
+    string      file_path;
+    string      type;
+    bool        always_show_run_output;
+  };
+  typedef std::map< string, test_info > test2info_map;  // key is test-name
+  test2info_map test2info;
 
 
 //  append_html  -------------------------------------------------------------//
 //  append_html  -------------------------------------------------------------//
 
 
@@ -151,17 +158,18 @@ namespace
       fs::ifstream file( pth );
       fs::ifstream file( pth );
       if ( !file )
       if ( !file )
       {
       {
-        string test_program, library_name;
-        test2prog_map::iterator itr( test2prog.find( test_name ) );
-        if ( itr != test2prog.end() )
+        test_info info;
+        string library_name;
+        test2info_map::iterator itr( test2info.find( test_name ) );
+        if ( itr != test2info.end() )
         {
         {
-          test_program = itr->second;
-          string::size_type start_pos( test_program.find( "libs/" ) );
+          info = itr->second;
+          string::size_type start_pos( info.file_path.find( "libs/" ) );
           if ( start_pos != string::npos )
           if ( start_pos != string::npos )
           {
           {
             start_pos += 5;
             start_pos += 5;
-            library_name = test_program.substr( start_pos,
-              test_program.find( '/', start_pos )-start_pos );
+            library_name = info.file_path.substr( start_pos,
+              info.file_path.find( '/', start_pos )-start_pos );
           }
           }
         }
         }
         m_root.reset( new xml::element( "test-log" ) );
         m_root.reset( new xml::element( "test-log" ) );
@@ -170,11 +178,16 @@ namespace
         m_root->attributes.push_back(
         m_root->attributes.push_back(
           xml::attribute( "test-name", test_name ) );
           xml::attribute( "test-name", test_name ) );
         m_root->attributes.push_back(
         m_root->attributes.push_back(
-          xml::attribute( "test-program", test_program ) );
+          xml::attribute( "test-type", info.type ) );
+        m_root->attributes.push_back(
+          xml::attribute( "test-program", info.file_path ) );
         m_root->attributes.push_back(
         m_root->attributes.push_back(
           xml::attribute( "target-directory", target_directory ) );
           xml::attribute( "target-directory", target_directory ) );
         m_root->attributes.push_back(
         m_root->attributes.push_back(
           xml::attribute( "toolset", toolset ) );
           xml::attribute( "toolset", toolset ) );
+        m_root->attributes.push_back(
+          xml::attribute( "show-run-output",
+            info.always_show_run_output ? "true" : "false" ) );
       }
       }
       else // existing file
       else // existing file
       {
       {
@@ -348,21 +361,24 @@ int cpp_main( int argc, char ** argv )
   {
   {
 //      std::cout << line << "\n";
 //      std::cout << line << "\n";
 
 
-    // create map of test-name to test-file-path
-    if ( line.find( "(boost-test " ) == 0 )
+    // create map of test-name to test-info
+    if ( line.find( "boost-test(" ) == 0 )
     {
     {
-      string test_name, test_file_path;
-      string::size_type colon = line.find( ":" );
-      if ( colon != string::npos )
-      {
-        test_name = line.substr( 13, colon-15 );
-        test_file_path = line.substr( colon+3,
-          line.find( "\"", colon+3 )-colon-3 );
-        convert_path_separators( test_file_path );
-        test2prog.insert( std::make_pair( test_name, test_file_path ) );
-//        std::cout << test_name << ", " << test_file_path << "\n";
-        continue;
-      }
+      string::size_type pos = line.find( '"' );
+      string test_name( line.substr( pos+1, line.find( '"', pos+1)-pos-1 ) );
+      test_info info;
+      info.always_show_run_output
+        = line.find( "\"always_show_run_output\"" ) != string::npos;
+      info.type = line.substr( 11, line.find( ')' )-11 );
+      for (int i = 0; i!=info.type.size(); ++i )
+        { info.type[i] = std::tolower( info.type[i] ); }
+      pos = line.find( ':' );
+      info.file_path = line.substr( pos+3,
+        line.find( "\"", pos+3 )-pos-3 );
+      convert_path_separators( info.file_path );
+      test2info.insert( std::make_pair( test_name, info ) );
+//      std::cout << test_name << ", " << info.type << ", " << info.file_path << "\n";
+      continue;
     }
     }
 
 
     // these actions represent both the start of a new action
     // these actions represent both the start of a new action

粤ICP备19079148号