process_jam_log.cpp 26 KB

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