RegTest : Add support for execution of a subset of tests

This commit is contained in:
Magne Sjaastad 2017-10-20 15:30:29 +02:00
parent bb549c6aed
commit 58cd4d112a
5 changed files with 39 additions and 12 deletions

View File

@ -1901,7 +1901,7 @@ void logInfoTextWithTimeInSeconds(const QTime& time, const QString& msg)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::runRegressionTest(const QString& testRootPath)
void RiaApplication::runRegressionTest(const QString& testRootPath, QStringList* testFilter)
{
m_runningRegressionTests = true;
@ -1921,6 +1921,28 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
QFileInfoList folderList = testDir.entryInfoList();
if (testFilter && testFilter->size() > 0)
{
QFileInfoList subset;
for (auto fi : folderList)
{
QString path = fi.path();
QString baseName = fi.baseName();
for (auto s : *testFilter)
{
QString trimmed = s.trimmed();
if (baseName.contains(trimmed))
{
subset.push_back(fi);
}
}
}
folderList = subset;
}
// delete diff and generated images
@ -2416,7 +2438,7 @@ bool RiaApplication::isRunningRegressionTests() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::executeRegressionTests(const QString& regressionTestPath)
void RiaApplication::executeRegressionTests(const QString& regressionTestPath, QStringList* testFilter)
{
RiuMainWindow* mainWnd = RiuMainWindow::instance();
if (mainWnd)
@ -2424,7 +2446,7 @@ void RiaApplication::executeRegressionTests(const QString& regressionTestPath)
mainWnd->hideAllDockWindows();
mainWnd->setDefaultWindowSize();
runRegressionTest(regressionTestPath);
runRegressionTest(regressionTestPath, testFilter);
mainWnd->loadWinGeoAndDockToolBarLayout();
}

View File

@ -97,7 +97,7 @@ public:
int parseArgumentsAndRunUnitTestsIfRequested();
bool parseArguments();
void executeRegressionTests(const QString& regressionTestPath);
void executeRegressionTests(const QString& regressionTestPath, QStringList* testFilter = nullptr);
void setActiveReservoirView(RimView*);
RimView* activeReservoirView();
@ -141,7 +141,7 @@ public:
void addWellLogsToModel(const QList<QString>& wellLogFilePaths);
void runMultiCaseSnapshots(const QString& templateProjectFileName, std::vector<QString> gridFileNames, const QString& snapshotFolderName);
void runRegressionTest(const QString& testRootPath);
void runRegressionTest(const QString& testRootPath, QStringList* testFilter = nullptr);
void processNonGuiEvents();

View File

@ -17,7 +17,9 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiaRegressionTest.h"
#include "cafPdmUiFilePathEditor.h"
#include "cafPdmUiTextEditor.h"
CAF_PDM_SOURCE_INIT(RiaRegressionTest, "RiaRegressionTest");
@ -30,10 +32,11 @@ RiaRegressionTest::RiaRegressionTest(void)
CAF_PDM_InitFieldNoDefault(&applicationWorkingFolder, "workingFolder", "Folder containing <b>compare</b>", "", "Location of compare tool from Image Magic suite", "");
applicationWorkingFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&regressionTestFolder, "regressionTestFolder", "Regression Test Folder", "", "", "");
regressionTestFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&regressionTestFolder, "regressionTestFolder", "Regression Test Folder", "", "", "");
CAF_PDM_InitField(&showInteractiveDiffImages, "showInteractiveDiffImages", false, "Interactive diff images", "", "", "");
CAF_PDM_InitFieldNoDefault(&testFilter, "testFilter", "Test Filter", "", "If empty, all tests are executed.\nTo execute a subset of tests, specify folder names separated by ;", "");
testFilter.uiCapability()->setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName());
}
//--------------------------------------------------------------------------------------------------

View File

@ -35,10 +35,9 @@ public:
public:
caf::PdmField<QString> applicationWorkingFolder;
caf::PdmField<QString> regressionTestFolder;
caf::PdmField<QString> testFilter;
caf::PdmField<bool> showInteractiveDiffImages;
protected:
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
};

View File

@ -1587,7 +1587,7 @@ void RiuMainWindow::slotShowRegressionTestDialog()
caf::PdmSettings::readFieldsFromApplicationStore(&regTestConfig);
caf::PdmUiPropertyViewDialog regressionTestDialog(this, &regTestConfig, "Regression Test", "");
regressionTestDialog.resize(QSize(600, 200));
regressionTestDialog.resize(QSize(600, 300));
if (regressionTestDialog.exec() == QDialog::Accepted)
{
@ -1597,7 +1597,10 @@ void RiuMainWindow::slotShowRegressionTestDialog()
QString currentApplicationPath = QDir::currentPath();
QDir::setCurrent(regTestConfig.applicationWorkingFolder);
app->executeRegressionTests(regTestConfig.regressionTestFolder);
QStringList testFilter = regTestConfig.testFilter().split(";", QString::SkipEmptyParts);
app->executeRegressionTests(regTestConfig.regressionTestFolder, &testFilter);
QDir::setCurrent(currentApplicationPath);
}