process_jam_log.cpp 24 KB

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