process_jam_log.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. // process jam regression test output into XML -----------------------------//
  2. // Copyright Beman Dawes 2002. Distributed under the Boost
  3. // Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/tools/regression for documentation.
  6. #include "detail/tiny_xml.hpp"
  7. #include "boost/filesystem/operations.hpp"
  8. #include "boost/filesystem/fstream.hpp"
  9. #include "boost/filesystem/exception.hpp"
  10. #include "boost/filesystem/convenience.hpp"
  11. #include <iostream>
  12. #include <string>
  13. #include <cstring>
  14. #include <map>
  15. #include <utility> // for make_pair
  16. #include <ctime>
  17. #include <cctype> // for tolower
  18. using std::string;
  19. namespace xml = boost::tiny_xml;
  20. namespace fs = boost::filesystem;
  21. #define BOOST_NO_CPP_MAIN_SUCCESS_MESSAGE
  22. #include <boost/test/included/prg_exec_monitor.hpp>
  23. // options
  24. static bool echo = false;
  25. static bool create_dirs = false;
  26. static bool boost_build_v2 = false;
  27. namespace
  28. {
  29. struct test_info
  30. {
  31. string file_path; // relative boost-root
  32. string type;
  33. bool always_show_run_output;
  34. };
  35. typedef std::map< string, test_info > test2info_map; // key is test-name
  36. test2info_map test2info;
  37. fs::path boost_root;
  38. fs::path locate_root; // ALL_LOCATE_TARGET (or boost_root if none)
  39. // append_html -------------------------------------------------------------//
  40. void append_html( const string & src, string & target )
  41. {
  42. // there are a few lines we want to ignore
  43. if ( src.find( "th target..." ) != string::npos
  44. || src.find( "cc1plus.exe: warning: changing search order for system directory" ) != string::npos
  45. || src.find( "cc1plus.exe: warning: as it has already been specified as a non-system directory" ) != string::npos
  46. ) return;
  47. // on some platforms (e.g. tru64cxx) the following line is a real performance boost
  48. target.reserve(src.size() * 2 + target.size());
  49. for ( string::size_type pos = 0; pos < src.size(); ++pos )
  50. {
  51. if ( src[pos] == '<' ) target += "&lt;";
  52. else if ( src[pos] == '>' ) target += "&gt;";
  53. else if ( src[pos] == '&' ) target += "&amp;";
  54. else target += src[pos];
  55. }
  56. }
  57. // timestamp ---------------------------------------------------------------//
  58. string timestamp()
  59. {
  60. char run_date[128];
  61. std::time_t tod;
  62. std::time( &tod );
  63. std::strftime( run_date, sizeof(run_date),
  64. "%Y-%m-%d %X UTC", std::gmtime( &tod ) );
  65. return string( run_date );
  66. }
  67. // convert path separators to forward slashes ------------------------------//
  68. void convert_path_separators( string & s )
  69. {
  70. for ( string::iterator itr = s.begin(); itr != s.end(); ++itr )
  71. if ( *itr == '\\' || *itr == '!' ) *itr = '/';
  72. }
  73. // trim_left ----------------------------------------------------------------//
  74. std::string trim_left( std::string const& s )
  75. {
  76. std::string::size_type const pos( s.find_first_not_of(' ') );
  77. return pos != std::string::npos
  78. ? s.substr( pos, s.size() - pos + 1 )
  79. : ""
  80. ;
  81. }
  82. // split --------------------------------------------------------------------//
  83. std::vector<std::string> split( std::string const& s )
  84. {
  85. std::string::size_type const pos( s.find_first_of(' ') );
  86. std::vector<std::string> result( 1, s.substr( 0, pos ) );
  87. if ( pos == std::string::npos )
  88. return result;
  89. std::vector<std::string> const rest( split( trim_left( s.substr( pos, s.size() - pos + 1 ) ) ) );
  90. result.insert( result.end(), rest.begin(), rest.end() );
  91. return result;
  92. }
  93. // extract a target directory path from a jam target string ----------------//
  94. // s may be relative to the initial_path:
  95. // ..\..\..\libs\foo\build\bin\libfoo.lib\vc7\debug\runtime-link-dynamic\boo.obj
  96. // s may be absolute:
  97. // d:\myboost\libs\foo\build\bin\libfoo.lib\vc7\debug\runtime-link-dynamic\boo.obj
  98. // return path is always relative to the boost directory tree:
  99. // libs/foo/build/bin/libfs.lib/vc7/debug/runtime-link-dynamic
  100. string target_directory( const string & s )
  101. {
  102. string temp( s );
  103. convert_path_separators( temp );
  104. string::size_type pos = temp.find_last_of( "/");
  105. if(pos == string::npos)
  106. temp = "./";
  107. else{
  108. temp.erase( pos ); // remove leaf
  109. temp = split( trim_left( temp ) ).back();
  110. if ( temp[0] == '.' ) temp.erase( 0, temp.find_first_not_of( "./" ) );
  111. else temp.erase( 0, locate_root.string().size()+1 );
  112. }
  113. if ( echo )
  114. std::cout << "\ttarget_directory( \"" << s << "\") -> \"" << temp << "\"" << std::endl;
  115. return temp;
  116. }
  117. string::size_type target_name_end( const string & s )
  118. {
  119. string::size_type pos = s.find( ".test/" );
  120. if ( pos == string::npos ) pos = s.find( ".dll/" );
  121. if ( pos == string::npos ) pos = s.find( ".so/" );
  122. if ( pos == string::npos ) pos = s.find( ".lib/" );
  123. if ( pos == string::npos ) pos = s.find( ".pyd/" );
  124. if ( pos == string::npos ) pos = s.find( ".a/" );
  125. return pos;
  126. }
  127. string toolset( const string & s )
  128. {
  129. string::size_type pos = target_name_end( s );
  130. if ( pos == string::npos ) pos = s.find( "build/" );
  131. if ( pos == string::npos ) return "";
  132. pos = s.find( "/", pos ) + 1;
  133. return s.substr( pos, s.find( "/", pos ) - pos );
  134. }
  135. string test_name( const string & s )
  136. {
  137. string::size_type pos = target_name_end( s );
  138. if ( pos == string::npos ) return "";
  139. string::size_type pos_start = s.rfind( '/', pos ) + 1;
  140. return s.substr( pos_start,
  141. (s.find( ".test/" ) != string::npos
  142. ? pos : s.find( "/", pos )) - pos_start );
  143. }
  144. // Take a path to a target directory of test, and
  145. // returns library name corresponding to that path.
  146. string test_path_to_library_name( string const& path )
  147. {
  148. // The path format is ...libs/.../something.test/....
  149. // So, the part between "libs" and "something.test" can be considered
  150. // as library name. But, for some libraries tests are located too deep,
  151. // say numeric/ublas/test/test1 directory, and some libraries have tests
  152. // in several subdirectories (regex/example and regex/test). So, its
  153. // not a "library name" as it may include subdirectories
  154. string::size_type end_pos = path.find(".test/");
  155. end_pos = path.rfind("/", end_pos);
  156. string::size_type start_pos;
  157. string::size_type pos = end_pos;
  158. unsigned int i;
  159. for(i = 0;; ++i){
  160. start_pos = path.rfind("/", pos - 1);
  161. if ( start_pos == string::npos )
  162. return string(); // empty string
  163. ++start_pos;
  164. const std::string dir = path.substr(start_pos, pos - start_pos);
  165. if(0 == i){
  166. // if this directory is either "test" or "example"
  167. // skip it in order to be compatible with testing.jam
  168. if("test" == dir
  169. || "example" == dir){
  170. end_pos = start_pos - 1;
  171. }
  172. }
  173. if("libs" == dir){
  174. start_pos = pos + 1;
  175. break;
  176. }
  177. pos = start_pos - 1;
  178. }
  179. return path.substr(start_pos, end_pos - start_pos);
  180. }
  181. // Tries to find target name in the string 'msg', starting from
  182. // position start.
  183. // If found, extract the directory name from the target name and
  184. // stores it in 'dir', and return the position after the target name.
  185. // Otherwise, returns string::npos.
  186. string::size_type parse_skipped_msg_aux(const string& msg,
  187. string::size_type start,
  188. string& dir)
  189. {
  190. dir.clear();
  191. string::size_type start_pos = msg.find( '<', start );
  192. if ( start_pos == string::npos ) return string::npos;
  193. ++start_pos;
  194. string::size_type end_pos = msg.find( '>', start_pos );
  195. dir += msg.substr( start_pos, end_pos - start_pos );
  196. if ( boost_build_v2 )
  197. {
  198. // The first letter is a magic value indicating
  199. // the type of grist.
  200. convert_path_separators( dir );
  201. dir.erase( 0, 1 );
  202. // We need path from root, not from 'status' dir.
  203. if (dir.find("../") == 0)
  204. dir.erase(0,3);
  205. else // dir is always relative to the boost directory tree
  206. dir.erase( 0, locate_root.string().size()+1 );
  207. }
  208. else
  209. {
  210. if ( dir[0] == '@' )
  211. {
  212. // new style build path, rooted build tree
  213. convert_path_separators( dir );
  214. dir.replace( 0, 1, "bin/" );
  215. }
  216. else
  217. {
  218. // old style build path, integrated build tree
  219. start_pos = dir.rfind( '!' );
  220. convert_path_separators( dir );
  221. string::size_type path_sep_pos = dir.find( '/', start_pos + 1 );
  222. if ( path_sep_pos != string::npos )
  223. dir.insert( path_sep_pos, "/bin" );
  224. else
  225. {
  226. // see http://article.gmane.org/gmane.comp.lib.boost.devel/146688;
  227. // the following code assumes that: a) 'dir' is not empty,
  228. // b) 'end_pos != string::npos' and c) 'msg' always ends with '...'
  229. if ( dir[dir.size() - 1] == '@' )
  230. dir += "/" + msg.substr( end_pos + 1, msg.size() - end_pos - 1 - 3 );
  231. }
  232. }
  233. }
  234. return end_pos;
  235. }
  236. // the format of paths is really kinky, so convert to normal form
  237. // first path is missing the leading "..\".
  238. // first path is missing "\bin" after "status".
  239. // second path is missing the leading "..\".
  240. // second path is missing "\bin" after "build".
  241. // second path uses "!" for some separators.
  242. void parse_skipped_msg( const string & msg,
  243. string & first_dir, string & second_dir )
  244. {
  245. string::size_type pos = parse_skipped_msg_aux(msg, 0, first_dir);
  246. if (pos == string::npos)
  247. return;
  248. parse_skipped_msg_aux(msg, pos, second_dir);
  249. }
  250. // test_log hides database details -----------------------------------------//
  251. class test_log
  252. : boost::noncopyable
  253. {
  254. const string & m_target_directory;
  255. xml::element_ptr m_root;
  256. public:
  257. test_log( const string & target_directory,
  258. const string & test_name,
  259. const string & toolset,
  260. bool force_new_file )
  261. : m_target_directory( target_directory )
  262. {
  263. if ( !force_new_file )
  264. {
  265. fs::path pth( locate_root / target_directory / "test_log.xml" );
  266. fs::ifstream file( pth );
  267. if ( file ) // existing file
  268. {
  269. try
  270. {
  271. m_root = xml::parse( file, pth.string() );
  272. return;
  273. }
  274. catch(...)
  275. {
  276. // unable to parse existing XML file, fall through
  277. }
  278. }
  279. }
  280. string library_name( test_path_to_library_name( target_directory ) );
  281. test_info info;
  282. test2info_map::iterator itr( test2info.find( library_name + "/" + test_name ) );
  283. if ( itr != test2info.end() )
  284. info = itr->second;
  285. if ( !info.file_path.empty() )
  286. library_name = test_path_to_library_name( info.file_path );
  287. if ( info.type.empty() )
  288. {
  289. if ( target_directory.find( ".lib/" ) != string::npos
  290. || target_directory.find( ".dll/" ) != string::npos
  291. || target_directory.find( ".so/" ) != string::npos
  292. || target_directory.find( ".dylib/" ) != string::npos
  293. || target_directory.find( "/build/" ) != string::npos
  294. )
  295. {
  296. info.type = "lib";
  297. }
  298. else if ( target_directory.find( ".pyd/" ) != string::npos )
  299. info.type = "pyd";
  300. }
  301. m_root.reset( new xml::element( "test-log" ) );
  302. m_root->attributes.push_back(
  303. xml::attribute( "library", library_name ) );
  304. m_root->attributes.push_back(
  305. xml::attribute( "test-name", test_name ) );
  306. m_root->attributes.push_back(
  307. xml::attribute( "test-type", info.type ) );
  308. m_root->attributes.push_back(
  309. xml::attribute( "test-program", info.file_path ) );
  310. m_root->attributes.push_back(
  311. xml::attribute( "target-directory", target_directory ) );
  312. m_root->attributes.push_back(
  313. xml::attribute( "toolset", toolset ) );
  314. m_root->attributes.push_back(
  315. xml::attribute( "show-run-output",
  316. info.always_show_run_output ? "true" : "false" ) );
  317. }
  318. ~test_log()
  319. {
  320. fs::path pth( locate_root / m_target_directory / "test_log.xml" );
  321. if ( create_dirs && !fs::exists( pth.branch_path() ) )
  322. fs::create_directories( pth.branch_path() );
  323. fs::ofstream file( pth );
  324. if ( !file )
  325. {
  326. std::cout << "*****Warning - can't open output file: "
  327. << pth.string() << "\n";
  328. }
  329. else xml::write( *m_root, file );
  330. }
  331. const string & target_directory() const { return m_target_directory; }
  332. void remove_action( const string & action_name )
  333. // no effect if action_name not found
  334. {
  335. xml::element_list::iterator itr;
  336. for ( itr = m_root->elements.begin();
  337. itr != m_root->elements.end() && (*itr)->name != action_name;
  338. ++itr ) {}
  339. if ( itr != m_root->elements.end() ) m_root->elements.erase( itr );
  340. }
  341. void add_action( const string & action_name,
  342. const string & result,
  343. const string & timestamp,
  344. const string & content )
  345. {
  346. remove_action( action_name );
  347. xml::element_ptr action( new xml::element(action_name) );
  348. m_root->elements.push_back( action );
  349. action->attributes.push_back( xml::attribute( "result", result ) );
  350. action->attributes.push_back( xml::attribute( "timestamp", timestamp ) );
  351. action->content = content;
  352. }
  353. };
  354. // message_manager maps input messages into test_log actions ---------------//
  355. class message_manager
  356. : boost::noncopyable
  357. {
  358. string m_action_name; // !empty() implies action pending
  359. // IOW, a start_message awaits stop_message
  360. string m_target_directory;
  361. string m_test_name;
  362. string m_toolset;
  363. bool m_note; // if true, run result set to "note"
  364. // set false by start_message()
  365. // data needed to stop further compile action after a compile failure
  366. // detected in the same target directory
  367. string m_previous_target_directory;
  368. bool m_compile_failed;
  369. public:
  370. message_manager() : m_note(false) {}
  371. ~message_manager() { /*assert( m_action_name.empty() );*/ }
  372. bool note() const { return m_note; }
  373. void note( bool value ) { m_note = value; }
  374. void start_message( const string & action_name,
  375. const string & target_directory,
  376. const string & test_name,
  377. const string & toolset,
  378. const string & prior_content )
  379. {
  380. assert( !target_directory.empty() );
  381. if ( !m_action_name.empty() ) stop_message( prior_content );
  382. m_action_name = action_name;
  383. m_target_directory = target_directory;
  384. m_test_name = test_name;
  385. m_toolset = toolset;
  386. m_note = false;
  387. if ( m_previous_target_directory != target_directory )
  388. {
  389. m_previous_target_directory = target_directory;
  390. m_compile_failed = false;
  391. }
  392. }
  393. void stop_message( const string & content )
  394. {
  395. if ( m_action_name.empty() ) return;
  396. stop_message( m_action_name, m_target_directory,
  397. "succeed", timestamp(), content );
  398. }
  399. void stop_message( const string & action_name,
  400. const string & target_directory,
  401. const string & result,
  402. const string & timestamp,
  403. const string & content )
  404. // the only valid action_names are "compile", "link", "run", "lib"
  405. {
  406. // My understanding of the jam output is that there should never be
  407. // a stop_message that was not preceeded by a matching start_message.
  408. // That understanding is built into message_manager code.
  409. assert( m_action_name == action_name );
  410. assert( m_target_directory == target_directory );
  411. assert( result == "succeed" || result == "fail" );
  412. // if test_log.xml entry needed
  413. if ( !m_compile_failed
  414. || action_name != "compile"
  415. || m_previous_target_directory != target_directory )
  416. {
  417. if ( action_name == "compile"
  418. && result == "fail" ) m_compile_failed = true;
  419. test_log tl( target_directory,
  420. m_test_name, m_toolset, action_name == "compile" );
  421. tl.remove_action( "lib" ); // always clear out lib residue
  422. // dependency removal
  423. if ( action_name == "lib" )
  424. {
  425. tl.remove_action( "compile" );
  426. tl.remove_action( "link" );
  427. tl.remove_action( "run" );
  428. }
  429. else if ( action_name == "compile" )
  430. {
  431. tl.remove_action( "link" );
  432. tl.remove_action( "run" );
  433. if ( result == "fail" ) m_compile_failed = true;
  434. }
  435. else if ( action_name == "link" )
  436. {
  437. tl.remove_action( "run" );
  438. }
  439. // dependency removal won't work right with random names, so assert
  440. else { assert( action_name == "run" ); }
  441. // add the "run" stop_message action
  442. tl.add_action( action_name,
  443. result == "succeed" && note() ? std::string("note") : result,
  444. timestamp, content );
  445. }
  446. m_action_name = ""; // signal no pending action
  447. m_previous_target_directory = target_directory;
  448. }
  449. };
  450. }
  451. // main --------------------------------------------------------------------//
  452. int cpp_main( int argc, char ** argv )
  453. {
  454. // Turn off synchronization with corresponding C standard library files. This
  455. // gives a significant speed improvement on platforms where the standard C++
  456. // streams are implemented using standard C files.
  457. std::ios::sync_with_stdio(false);
  458. if ( argc <= 1 )
  459. std::cout << "Usage: bjam [bjam-args] | process_jam_log [--echo] [--create-directories] [--v2] [locate-root]\n"
  460. "locate-root - the same as the bjam ALL_LOCATE_TARGET\n"
  461. " parameter, if any. Default is boost-root.\n"
  462. "create-directories - if the directory for xml file doesn't exists - creates it.\n"
  463. " usually used for processing logfile on different machine\n";
  464. boost_root = fs::initial_path();
  465. while ( !boost_root.empty()
  466. && !fs::exists( boost_root / "libs" ) )
  467. {
  468. boost_root /= "..";
  469. }
  470. if ( boost_root.empty() )
  471. {
  472. std::cout << "must be run from within the boost-root directory tree\n";
  473. return 1;
  474. }
  475. boost_root.normalize();
  476. if ( argc > 1 && std::strcmp( argv[1], "--echo" ) == 0 )
  477. {
  478. echo = true;
  479. --argc; ++argv;
  480. }
  481. if (argc > 1 && std::strcmp( argv[1], "--create-directories" ) == 0 )
  482. {
  483. create_dirs = true;
  484. --argc; ++argv;
  485. }
  486. if ( argc > 1 && std::strcmp( argv[1], "--v2" ) == 0 )
  487. {
  488. boost_build_v2 = true;
  489. --argc; ++argv;
  490. }
  491. if (argc > 1)
  492. {
  493. locate_root = fs::path( argv[1], fs::native );
  494. if ( !locate_root.is_complete() )
  495. locate_root = ( fs::initial_path() / locate_root ).normalize();
  496. --argc; ++argv;
  497. }
  498. else
  499. {
  500. locate_root = boost_root;
  501. }
  502. std::cout << "boost_root: " << boost_root.string() << '\n'
  503. << "locate_root: " << locate_root.string() << '\n';
  504. message_manager mgr;
  505. string line;
  506. string content;
  507. bool capture_lines = false;
  508. std::istream* input;
  509. if (argc > 1)
  510. {
  511. input = new std::ifstream(argv[1]);
  512. }
  513. else
  514. {
  515. input = &std::cin;
  516. }
  517. // This loop looks at lines for certain signatures, and accordingly:
  518. // * Calls start_message() to start capturing lines. (start_message() will
  519. // automatically call stop_message() if needed.)
  520. // * Calls stop_message() to stop capturing lines.
  521. // * Capture lines if line capture on.
  522. int line_num = 0;
  523. while ( std::getline( *input, line ) )
  524. {
  525. ++line_num;
  526. std::vector<std::string> const line_parts( split( line ) );
  527. std::string const line_start( line_parts[0] != "...failed"
  528. ? line_parts[0]
  529. : line_parts[0] + " " + line_parts[1]
  530. );
  531. if ( echo )
  532. {
  533. std::cout
  534. << "line " << line_num << ": " << line << "\n"
  535. << "\tline_start: " << line_start << "\n";
  536. }
  537. // create map of test-name to test-info
  538. if ( line_start.find( "boost-test(" ) == 0 )
  539. {
  540. string::size_type pos = line.find( '"' );
  541. string test_name( line.substr( pos+1, line.find( '"', pos+1)-pos-1 ) );
  542. test_info info;
  543. info.always_show_run_output
  544. = line.find( "\"always_show_run_output\"" ) != string::npos;
  545. info.type = line.substr( 11, line.find( ')' )-11 );
  546. for (unsigned int i = 0; i!=info.type.size(); ++i )
  547. { info.type[i] = std::tolower( info.type[i] ); }
  548. pos = line.find( ':' );
  549. // the rest of line is missing if bjam didn't know how to make target
  550. if ( pos + 1 != line.size() )
  551. {
  552. info.file_path = line.substr( pos+3,
  553. line.find( "\"", pos+3 )-pos-3 );
  554. convert_path_separators( info.file_path );
  555. if ( info.file_path.find( "libs/libs/" ) == 0 ) info.file_path.erase( 0, 5 );
  556. if ( test_name.find( "/" ) == string::npos )
  557. test_name = "/" + test_name;
  558. test2info.insert( std::make_pair( test_name, info ) );
  559. // std::cout << test_name << ", " << info.type << ", " << info.file_path << "\n";
  560. }
  561. else
  562. {
  563. std::cout << "*****Warning - missing test path: " << line << "\n"
  564. << " (Usually occurs when bjam doesn't know how to make a target)\n";
  565. }
  566. continue;
  567. }
  568. // these actions represent both the start of a new action
  569. // and the end of a failed action
  570. else if ( line_start.find( "C++-action" ) != string::npos
  571. || line_start.find( "vc-C++" ) != string::npos
  572. || line_start.find( "C-action" ) != string::npos
  573. || line_start.find( "Cc-action" ) != string::npos
  574. || line_start.find( "vc-Cc" ) != string::npos
  575. || line_start.find( ".compile.") != string::npos
  576. || line_start.find( "compile-") != string::npos
  577. || line_start.find( "-compile") != string::npos
  578. || line_start.find( "Link-action" ) != string::npos
  579. || line_start.find( "vc-Link" ) != string::npos
  580. || line_start.find( "Archive-action" ) != string::npos
  581. || line_start.find( ".archive") != string::npos
  582. || ( line_start.find( ".link") != string::npos &&
  583. // .linkonce is present in gcc linker messages about
  584. // unresolved symbols. We don't have to parse those
  585. line_start.find( ".linkonce" ) == string::npos )
  586. )
  587. {
  588. string action( ( line_start.find( "Link-action" ) != string::npos
  589. || line_start.find( "vc-Link" ) != string::npos
  590. || line_start.find( "Archive-action" ) != string::npos
  591. || line_start.find( ".archive") != string::npos
  592. || line_start.find( ".link") != string::npos
  593. )
  594. ? "link" : "compile"
  595. );
  596. if ( line_start.find( "...failed " ) != string::npos )
  597. {
  598. mgr.stop_message( action, target_directory( line ),
  599. "fail", timestamp(), content );
  600. }
  601. else
  602. {
  603. string target_dir( target_directory( line ) );
  604. mgr.start_message( action, target_dir,
  605. test_name( target_dir ), toolset( target_dir ), content );
  606. }
  607. content = "\n";
  608. capture_lines = true;
  609. }
  610. // these actions are only used to stop the previous action
  611. else if ( line_start.find( "-Archive" ) != string::npos
  612. || line_start.find( "MkDir" ) == 0 )
  613. {
  614. mgr.stop_message( content );
  615. content.clear();
  616. capture_lines = false;
  617. }
  618. else if ( line_start.find( "execute-test" ) != string::npos
  619. || line_start.find( "capture-output" ) != string::npos )
  620. {
  621. if ( line_start.find( "...failed " ) != string::npos )
  622. {
  623. mgr.stop_message( "run", target_directory( line ),
  624. "fail", timestamp(), content );
  625. content = "\n";
  626. capture_lines = true;
  627. }
  628. else
  629. {
  630. string target_dir( target_directory( line ) );
  631. mgr.start_message( "run", target_dir,
  632. test_name( target_dir ), toolset( target_dir ), content );
  633. // contents of .output file for content
  634. capture_lines = false;
  635. content = "\n";
  636. fs::ifstream file( locate_root / target_dir
  637. / (test_name(target_dir) + ".output") );
  638. if ( file )
  639. {
  640. string ln;
  641. while ( std::getline( file, ln ) )
  642. {
  643. if ( ln.find( "<note>" ) != string::npos ) mgr.note( true );
  644. append_html( ln, content );
  645. content += "\n";
  646. }
  647. }
  648. }
  649. }
  650. // bjam indicates some prior dependency failed by a "...skipped" message
  651. else if ( line_start.find( "...skipped" ) != string::npos
  652. && line.find( "<directory-grist>" ) == string::npos
  653. )
  654. {
  655. mgr.stop_message( content );
  656. content.clear();
  657. capture_lines = false;
  658. if ( line.find( " for lack of " ) != string::npos )
  659. {
  660. capture_lines = ( line.find( ".run for lack of " ) == string::npos );
  661. string target_dir;
  662. string lib_dir;
  663. parse_skipped_msg( line, target_dir, lib_dir );
  664. if ( target_dir != lib_dir ) // it's a lib problem
  665. {
  666. mgr.start_message( "lib", target_dir,
  667. test_name( target_dir ), toolset( target_dir ), content );
  668. content = lib_dir;
  669. mgr.stop_message( "lib", target_dir, "fail", timestamp(), content );
  670. content = "\n";
  671. }
  672. }
  673. }
  674. else if ( line_start.find( "**passed**" ) != string::npos
  675. || line_start.find( "failed-test-file" ) != string::npos
  676. || line_start.find( "command-file-dump" ) != string::npos )
  677. {
  678. mgr.stop_message( content );
  679. content = "\n";
  680. capture_lines = true;
  681. }
  682. else if ( capture_lines ) // hang onto lines for possible later use
  683. {
  684. append_html( line, content );;
  685. content += "\n";
  686. }
  687. }
  688. mgr.stop_message( content );
  689. if (input != &std::cin)
  690. delete input;
  691. return 0;
  692. }
粤ICP备19079148号