Fixed unit tests

This commit is contained in:
Daniel Marjamäki 2017-05-30 15:53:54 +02:00
parent 1f48b082d1
commit dc79f9630f
2 changed files with 9 additions and 5 deletions

View File

@ -78,12 +78,13 @@
/*static*/ FILE* CppCheckExecutor::exceptionOutput = stdout; /*static*/ FILE* CppCheckExecutor::exceptionOutput = stdout;
CppCheckExecutor::CppCheckExecutor() CppCheckExecutor::CppCheckExecutor()
: _settings(0), time1(0), errorOutput(stderr), errorlist(false) : _settings(0), time1(0), errorOutput(nullptr), errorlist(false)
{ {
} }
CppCheckExecutor::~CppCheckExecutor() CppCheckExecutor::~CppCheckExecutor()
{ {
delete errorOutput;
} }
bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* const argv[]) bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* const argv[])
@ -809,7 +810,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
time1 = std::time(0); time1 = std::time(0);
if (!settings.outputFile.empty()) { if (!settings.outputFile.empty()) {
errorOutput = fopen(settings.outputFile.c_str(), "wt"); errorOutput = new std::ofstream(settings.outputFile);
} }
if (settings.xml) { if (settings.xml) {
@ -927,7 +928,10 @@ void CppCheckExecutor::reportErr(const std::string &errmsg)
return; return;
_errorList.insert(errmsg); _errorList.insert(errmsg);
std::fprintf(errorOutput, "%s\n", errmsg.c_str()); if (errorOutput)
*errorOutput << errmsg << std::endl;
else
std::cerr << errmsg << std::endl;
} }
void CppCheckExecutor::reportOut(const std::string &outmsg) void CppCheckExecutor::reportOut(const std::string &outmsg)

View File

@ -177,9 +177,9 @@ private:
static FILE* exceptionOutput; static FILE* exceptionOutput;
/** /**
* Error output (default stderr) * Error output
*/ */
FILE* errorOutput; std::ofstream *errorOutput;
/** /**
* Has --errorlist been given? * Has --errorlist been given?