📄 library_status.cpp
字号:
} // column header-----------------------------------------------------------// int header_depth(const col_node & root){ col_node::subcolumns_t::const_iterator itr; int max_depth = 1; for(itr = root.m_subcolumns.begin(); itr != root.m_subcolumns.end(); ++itr){ max_depth = std::max(max_depth, itr->second.rows); } return max_depth; } void header_cell(int rows, int cols, const std::string & name){ // add row cells report << "<td align=\"center\" " ; if(1 < cols) report << "colspan=\"" << cols << "\" " ; if(1 < rows) // span rows to the end the header report << "rowspan=\"" << rows << "\" " ; report << ">" ; report << name; report << "</td>\n"; } void emit_column_headers( const col_node & node, int display_row, int current_row, int row_count ){ if(current_row < display_row){ if(! node.m_subcolumns.empty()){ col_node::subcolumns_t::const_iterator itr; for(itr = node.m_subcolumns.begin(); itr != node.m_subcolumns.end(); ++itr){ emit_column_headers(itr->second, display_row, current_row + 1, row_count); } } return; } if(node.has_leaf && ! node.m_subcolumns.empty()){ header_cell(row_count - current_row, 1, std::string("")); } col_node::subcolumns_t::const_iterator itr; for(itr = node.m_subcolumns.begin(); itr != node.m_subcolumns.end(); ++itr){ if(1 == itr->second.rows) header_cell(row_count - current_row, itr->second.cols, itr->first); else header_cell(1, itr->second.cols, itr->first); } } fs::path find_lib_test_dir(){ // walk up from the path were we started until we find // bin or bin.v2 fs::path::const_iterator leaf_itr = fs::initial_path().end(); fs::path test_lib_dir = fs::initial_path(); for(;;){ if(fs::is_directory( test_lib_dir / "bin.v2")){ test_lib_dir /= "bin.v2"; break; } if(fs::is_directory( test_lib_dir / "bin")){ // v1 includes the word boost test_lib_dir /= "bin"; test_lib_dir /= "boost"; break; } if(test_lib_dir.empty()) throw std::string("binary path not found"); if(*leaf_itr != "libs") --leaf_itr; test_lib_dir.remove_leaf(); } if(leaf_itr == fs::initial_path().end()) throw std::string("must be run from within a library directory"); while(leaf_itr != fs::initial_path().end()){ test_lib_dir /= *leaf_itr++; // append "libs" } return test_lib_dir; } // note : uncomment the #if/#endif and what this compile !!! string find_lib_name(fs::path lib_test_dir){ unsigned int count; fs::path::iterator e_itr = lib_test_dir.end(); for(count = 0;; ++count){ if(*--e_itr == "libs") break; if(lib_test_dir.empty()) throw std::string("must be run from within a library directory"); } string library_name; for(;;){ library_name.append(*++e_itr); if(1 == --count) break; library_name.append("/"); } return library_name; } fs::path find_boost_root(){ fs::path boost_root = fs::initial_path(); for(;;){ if(fs::is_directory( boost_root / "boost")){ break; } if(boost_root.empty()) throw std::string("boost root not found"); boost_root.remove_leaf(); } return boost_root; } // do_table ----------------------------------------------------------------// void do_table(const string & lib_name) { col_node root_node; fs::path lib_test_dir = find_lib_test_dir(); for ( fs::directory_iterator itr(lib_test_dir); itr != end_itr; ++itr ) { if(! fs::is_directory(*itr)) continue; build_node_tree(*itr, root_node); } // visit directory nodes and record nodetree report << "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n"; // emit root_node.get_spans(); int row_count = header_depth(root_node); report << "<tr>\n"; report << "<td rowspan=\"" << row_count << "\">Test Name</td>\n"; // emit column headers int row_index = 0; for(;;){ emit_column_headers(root_node, row_index, 0, row_count); report << "</tr>" ; if(++row_index == row_count) break; report << "<tr>\n"; } // now the rest of the table body do_table_body(root_node, lib_name, lib_test_dir); report << "</table>\n"; }}// unnamed namespace// main --------------------------------------------------------------------//#define BOOST_NO_CPP_MAIN_SUCCESS_MESSAGE#include <boost/test/included/prg_exec_monitor.hpp>int cpp_main( int argc, char * argv[] ) // note name!{ fs::path comment_path; while ( argc > 1 && *argv[1] == '-' ) { if ( argc > 2 && std::strcmp( argv[1], "--compiler" ) == 0 ) { specific_compiler = argv[2]; --argc; ++argv; } else if ( argc > 2 && std::strcmp( argv[1], "--locate-root" ) == 0 ) { locate_root = fs::path( argv[2], fs::native ); --argc; ++argv; } else if ( argc > 2 && std::strcmp( argv[1], "--boost-root" ) == 0 ) { boost_root = fs::path( argv[2], fs::native ); --argc; ++argv; } else if ( argc > 2 && std::strcmp( argv[1], "--comment" ) == 0 ) { comment_path = fs::path( argv[2], fs::native ); --argc; ++argv; } else if ( argc > 2 && std::strcmp( argv[1], "--notes" ) == 0 ) { notes_path = fs::path( argv[2], fs::native ); --argc; ++argv; } else if ( argc > 2 && std::strcmp( argv[1], "--notes-map" ) == 0 ) { notes_map_path = fs::path( argv[2], fs::native ); --argc; ++argv; } else if ( std::strcmp( argv[1], "--ignore-pass" ) == 0 ) ignore_pass = true; else if ( std::strcmp( argv[1], "--no-warn" ) == 0 ) no_warn = true; else if ( std::strcmp( argv[1], "--v2" ) == 0 ) {--argc; ++argv ;} // skip else if ( argc > 2 && std::strcmp( argv[1], "--jamfile" ) == 0) {--argc; ++argv;} // skip else { std::cerr << "Unknown option: " << argv[1] << "\n"; argc = 1; } --argc; ++argv; } if ( argc != 2 && argc != 3 ) { std::cerr << "Usage: library_status [options...] status-file [links-file]\n" " boost-root is the path to the boost tree root directory.\n" " status-file and links-file are paths to the output files.\n" " options: --compiler name Run for named compiler only\n" " --ignore-pass Do not report tests which pass all compilers\n" " --no-warn Warnings not reported if test passes\n" " --boost-root path default derived from current path.\n" " --locate-root path Path to ALL_LOCATE_TARGET for bjam;\n" " default boost-root.\n" " --comment path Path to file containing HTML\n" " to be copied into status-file.\n" " --notes path Path to file containing HTML\n" " to be copied into status-file.\n" " --notes-map path Path to file of toolset/test,n lines, where\n" " n is number of note bookmark in --notes file.\n" "Example: compiler_status --compiler gcc /boost-root cs.html cs-links.html\n" "Note: Only the leaf of the links-file path and --notes file string are\n" "used in status-file HTML links. Thus for browsing, status-file,\n" "links-file, and --notes file must all be in the same directory.\n" ; return 1; } if(boost_root.empty()) boost_root = find_boost_root(); if ( locate_root.empty() ) locate_root = boost_root; report.open( fs::path( argv[1], fs::native ) ); if ( !report ) { std::cerr << "Could not open report output file: " << argv[2] << std::endl; return 1; } if ( argc == 3 ) { fs::path links_path( argv[2], fs::native ); links_name = links_path.leaf(); links_file.open( links_path ); if ( !links_file ) { std::cerr << "Could not open links output file: " << argv[3] << std::endl; return 1; } } else no_links = true; build_notes_bookmarks(); const string library_name = find_lib_name(fs::initial_path()); char run_date[128]; std::time_t tod; std::time( &tod ); std::strftime( run_date, sizeof(run_date), "%X UTC, %A %d %B %Y", std::gmtime( &tod ) ); report << "<html>\n" << "<head>\n" << "<title>Boost Library Status Automatic Test</title>\n" << "</head>\n" << "<body bgcolor=\"#ffffff\" text=\"#000000\">\n" << "<table border=\"0\">\n" << "<tr>\n" << "<td><img border=\"0\" " << "src=\"" << boost_root / "boost.png" << "\" width=\"277\" " << "height=\"86\"></td>\n" << "<td>\n" << "<h1>Library Status: " + library_name + "</h1>\n" << "<b>Run Date:</b> " << run_date << "\n" ; if ( !comment_path.empty() ) { fs::ifstream comment_file( comment_path ); if ( !comment_file ) { std::cerr << "Could not open \"--comment\" input file: " << comment_path.string() << std::endl; return 1; } char c; while ( comment_file.get( c ) ) { report.put( c ); } } report << "</td>\n</table>\n<br>\n"; if ( !no_links ) { links_file << "<html>\n" << "<head>\n" << "<title>Boost Library Status Error Log</title>\n" << "</head>\n" << "<body bgcolor=\"#ffffff\" text=\"#000000\">\n" << "<table border=\"0\">\n" << "<tr>\n" << "<td><img border=\"0\" src=\"" << boost_root / "boost.png" << "\" width=\"277\" " << "height=\"86\"></td>\n" << "<td>\n" << "<h1>Library Status: " + library_name + "</h1>\n" << "<b>Run Date:</b> " << run_date << "\n</td>\n</table>\n<br>\n" ; } do_table(library_name); if ( load_notes_html() ) report << notes_html << "\n"; report << "</body>\n" "</html>\n" ; if ( !no_links ) { links_file << "</body>\n" "</html>\n" ; } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -