CTimeSpan HH_Runtime::ExecuteUnitTest( const std::string& batchBuildId ) { // Save off the start time __time64_t startTime; _time64( &startTime ); CTimeSpan startTimeSpan( startTime ); m_notifier.ReportProgressMessage( "Executing unit test..." ); if ( _access( m_exePath.c_str(), 00 ) != 0 ) { throw HH_CantFindUnitTestExecutable( m_exePath ); } if ( _access( m_dotInputFileName.c_str(), 00 ) != 0 ) { throw HH_CantOpenInputFile( m_dotInputFileName ); } { HH_File inputFile( m_dotInputFileName, "r" ); HH_File processedFile( m_dotPreprocessedFileName, "w" ); PreprocessInputFile( inputFile, processedFile ); } std::ostringstream commandStream; commandStream << m_exePath << " -batch < " << m_dotPreprocessedFileName << " > " << m_dotOutputFileName; system( commandStream.str().c_str() ); VerifyUnitTestResults( batchBuildId ); if ( _unlink( m_dotPreprocessedFileName.c_str() ) == -1 ) { std::string message = "Can't remove '"; message += m_dotPreprocessedFileName; message += "'"; throw HH_ErrnoError( message, errno ); } // Compute the total time for test execution __time64_t endTime; _time64( &endTime ); CTimeSpan endTimeSpan( endTime ); return endTimeSpan - startTimeSpan; }
extern int RcPass1IoInit( void ) /******************************/ /* Open the two files for input and output. The input stream starts at the */ /* top infilename and continues as the directives in the file indicate */ /* Returns false if there is a problem opening one of the files. */ { int error; char *includepath = NULL; if( !CmdLineParms.IgnoreINCLUDE ) { if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN16 ) { includepath = RcGetEnv( "WINDOWS_INCLUDE" ); } else if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) { includepath = RcGetEnv( "NT_INCLUDE" ); } else if( CmdLineParms.TargetOS == RC_TARGET_OS_OS2 ) { includepath = RcGetEnv( "OS2_INCLUDE" ); } if( includepath != NULL ) { PP_AddIncludePath( includepath ); } includepath = RcGetEnv( "INCLUDE" ); if( includepath != NULL ) { PP_AddIncludePath( includepath ); } } if( !CmdLineParms.NoPreprocess ) { if( PreprocessInputFile() ) { return( FALSE ); } } RcIoTextInputInit(); error = RcIoPushInputFile( CmdLineParms.InFileName ); if( error ) return( FALSE ); if( !CmdLineParms.PreprocessOnly ) { error = Pass1InitRes(); } if( error ) { PP_Fini(); RcIoTextInputShutdown(); return( FALSE ); } return( TRUE ); }
void HH_Runtime::PreprocessInputFile( HH_File& inputFile, HH_File& processedFile ) { bool eof = false; do { std::string stringRead = inputFile.GetLine( eof ); char buffer[10240]; const char *includeCommand = "@include "; strcpy_s( buffer, stringRead.c_str() ); if ( strncmp( buffer, includeCommand, strlen( includeCommand ) ) == 0 ) { char* pNewLine = strrchr( buffer, '\n' ); if ( pNewLine != NULL ) { *pNewLine = '\0'; } char* p = &buffer[ strlen( includeCommand ) ]; while ( p != NULL && *p == ' ' ) { ++p; } std::string includeFileName = p; HH_File inputFile( includeFileName, "r" ); processedFile.PutLine( std::string( "# " ) + includeCommand + "\"" + includeFileName + "\"\n" ); PreprocessInputFile( inputFile, processedFile ); } else { processedFile.PutLine( stringRead ); } } while ( !eof ); }