static Boolean _writeStr( iOFile inst, const char* buffer ) { iOFileData data = Data(inst); long s = StrOp.len( buffer ); return _writeFile( inst, buffer, s ); }
void ScriptTest::runTest() { // before we start remove any temporary files that we generated last time. _removeFile(_script + ".stdout.failed"); _removeFile(_script + ".stderr.failed"); _removeFile(_script + ".stdout.failed.stripped"); _removeFile(_script + ".stderr.failed.stripped"); _removeFile(_script + ".stdout.first"); _removeFile(_script + ".stderr.first"); _removeFile(_script + ".stdout.first.stripped"); _removeFile(_script + ".stderr.first.stripped"); _removeFile(_script + ".stdout.stripped"); _removeFile(_script + ".stderr.stripped"); _runProcess(); if (QFile(_script + ".stdout").exists() == false || QFile(_script + ".stderr").exists() == false) { LOG_WARN("STDOUT or STDERR doesn't exist for " + _script + "\n*************************\n" " This can be resolved by reviewing the output for correctness and then \n" " creating a new baseline. E.g.\n" " verify: \n" " less " + _script + ".stdout.first\n" " less " + _script + ".stderr.first\n" " ### NOTE: If the test is comparing against a known good file (e.g. .osm\n" " ### then it may be better to update that file. You'll have to look at\n" " ### the source files to be sure.\n" " Make a new baseline:\n" " mv " + _script + ".stdout.first " + _script + ".stdout\n" " mv " + _script + ".stderr.first " + _script + ".stderr\n" "*************************\n" ); _baseStderr = "<invalid/>"; _baseStdout = "<invalid/>"; _writeFile(_script + ".stdout.first", _stdout); _writeFile(_script + ".stderr.first", _stderr); _writeFile(_script + ".stdout.first.stripped", _removeIgnoredSubstrings(_stdout)); _writeFile(_script + ".stderr.first.stripped", _removeIgnoredSubstrings(_stderr)); CPPUNIT_ASSERT_MESSAGE(QString("STDOUT or STDERR does not exist").toStdString(), false); } _baseStderr = _readFile(_script + ".stderr"); _baseStdout = _readFile(_script + ".stdout"); bool failed = false; if (_removeIgnoredSubstrings(_baseStdout) != _removeIgnoredSubstrings(_stdout)) { _writeFile(_script + ".stdout.failed", _stdout); _writeFile(_script + ".stdout.failed.stripped", _removeIgnoredSubstrings(_stdout)); _writeFile(_script + ".stdout.stripped", _removeIgnoredSubstrings(_baseStdout)); if (_printDiff) { LOG_WARN("STDOUT does not match for:\n" + _script + ".stdout" + " " + _script + ".stdout.failed"); _runDiff(_script + ".stdout.stripped", _script + ".stdout.failed.stripped"); } else { LOG_WARN("STDOUT does not match for:\n" + _script + ".stdout.failed" + " " + _script + ".stdout\n" "\n*************************\n" " This can be resolved by reviewing the output for correctness and then \n" " creating a new baseline. E.g.\n" " verify: \n" " diff " + _script + ".stdout.stripped " + _script + ".stdout.failed.stripped\n" " ### NOTE: If the test is comparing against a known good file (e.g. .osm\n" " ### then it may be better to update that file. You'll have to look at\n" " ### the source files to be sure.\n" " Make a new baseline:\n" " mv " + _script + ".stdout.failed " + _script + ".stdout\n" "*************************\n" ); } failed = true; } if (_removeIgnoredSubstrings(_baseStderr) != _removeIgnoredSubstrings(_stderr)) { _writeFile(_script + ".stderr.failed", _stderr); _writeFile(_script + ".stderr.failed.stripped", _removeIgnoredSubstrings(_stderr)); _writeFile(_script + ".stderr.stripped", _removeIgnoredSubstrings(_baseStderr)); if (_printDiff) { LOG_WARN("STDERR does not match for:\n" + _script + ".stderr" + " " + _script + ".stderr.failed"); _runDiff(_script + ".stderr.stripped", _script + ".stderr.failed.stripped"); } else { LOG_WARN("STDERR does not match for:\n" + _script + ".stderr.failed" + " " + _script + ".stderr\n" "\n*************************\n" " This can be resolved by reviewing the output for correctness and then \n" " creating a new baseline. E.g.\n" " verify: \n" " diff " + _script + ".stderr.stripped " + _script + ".stderr.failed.stripped\n" " ### NOTE: If the test is comparing against a known good file (e.g. .osm\n" " ### then it may be better to update that file. You'll have to look at\n" " ### the source files to be sure.\n" " Make a new baseline:\n" " mv " + _script + ".stderr.failed " + _script + ".stderr\n" "*************************\n" ); } failed = true; } if (failed) { CPPUNIT_ASSERT_MESSAGE(QString("STDOUT or STDERR does not match").toStdString(), false); } }