Regression tests : Add basic timing with reporting by logging

This commit is contained in:
Magne Sjaastad 2017-04-20 22:34:15 +02:00
parent 9d5fcaf5a1
commit ed2010c0b7

View File

@ -2259,6 +2259,18 @@ void removeDirectoryWithContent(QDir dirToDelete )
dirToDelete.rmdir("."); dirToDelete.rmdir(".");
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void logInfoTextWithTimeInSeconds(const QTime& time, const QString& msg)
{
double timeRunning = time.elapsed() / 1000.0;
QString timeText = QString("(%1 s) ").arg(timeRunning, 0, 'f', 1);
RiaLogging::info(timeText + msg);
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -2315,6 +2327,11 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
} }
} }
QTime timeStamp;
timeStamp.start();
logInfoTextWithTimeInSeconds(timeStamp, "Starting regression tests\n");
for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx) for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx)
{ {
QDir testCaseFolder(folderList[dirIdx].filePath()); QDir testCaseFolder(folderList[dirIdx].filePath());
@ -2351,44 +2368,51 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
if (!projectFileName.isEmpty()) if (!projectFileName.isEmpty())
{ {
loadProject(testCaseFolder.filePath(projectFileName)); logInfoTextWithTimeInSeconds(timeStamp, "Initializing test :" + testCaseFolder.absolutePath());
// Wait until all command objects have completed loadProject(testCaseFolder.filePath(projectFileName));
while (!m_commandQueueLock.tryLock())
{
processEvents();
}
m_commandQueueLock.unlock();
regressionTestConfigureProject(); // Wait until all command objects have completed
while (!m_commandQueueLock.tryLock())
{
processEvents();
}
m_commandQueueLock.unlock();
QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath(generatedFolderName); regressionTestConfigureProject();
saveSnapshotForAllViews(fullPathGeneratedFolder);
RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(fullPathGeneratedFolder); QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath(generatedFolderName);
saveSnapshotForAllViews(fullPathGeneratedFolder);
QDir baseDir(testCaseFolder.filePath(baseFolderName)); RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(fullPathGeneratedFolder);
QDir genDir(testCaseFolder.filePath(generatedFolderName));
QDir diffDir(testCaseFolder.filePath(diffFolderName));
if (!diffDir.exists()) testCaseFolder.mkdir(diffFolderName);
baseDir.setFilter(QDir::Files);
QStringList baseImageFileNames = baseDir.entryList();
for (int fIdx = 0; fIdx < baseImageFileNames.size(); ++fIdx) QDir baseDir(testCaseFolder.filePath(baseFolderName));
{ QDir genDir(testCaseFolder.filePath(generatedFolderName));
QString fileName = baseImageFileNames[fIdx]; QDir diffDir(testCaseFolder.filePath(diffFolderName));
RiaImageFileCompare imgComparator(RegTestNames::imageCompareExeName); if (!diffDir.exists()) testCaseFolder.mkdir(diffFolderName);
bool ok = imgComparator.runComparison(genDir.filePath(fileName), baseDir.filePath(fileName), diffDir.filePath(fileName)); baseDir.setFilter(QDir::Files);
if (!ok) QStringList baseImageFileNames = baseDir.entryList();
{
for (int fIdx = 0; fIdx < baseImageFileNames.size(); ++fIdx)
{
QString fileName = baseImageFileNames[fIdx];
RiaImageFileCompare imgComparator(RegTestNames::imageCompareExeName);
bool ok = imgComparator.runComparison(genDir.filePath(fileName), baseDir.filePath(fileName), diffDir.filePath(fileName));
if (!ok)
{
qDebug() << "Error comparing :" << imgComparator.errorMessage() << "\n" << imgComparator.errorDetails(); qDebug() << "Error comparing :" << imgComparator.errorMessage() << "\n" << imgComparator.errorDetails();
} }
} }
closeProject(); closeProject();
logInfoTextWithTimeInSeconds(timeStamp, "Completed test :" + testCaseFolder.absolutePath());
} }
} }
RiaLogging::info("\n");
logInfoTextWithTimeInSeconds(timeStamp, "Completed regression tests");
m_runningRegressionTests = false; m_runningRegressionTests = false;
} }