#2554 Regression Test : Reorganize setting of current working folder

This commit is contained in:
Magne Sjaastad 2018-03-06 17:59:40 +01:00
parent 2e122d2ab3
commit 91428a028d
6 changed files with 36 additions and 21 deletions

View File

@ -28,6 +28,7 @@
#include "RiaLogging.h" #include "RiaLogging.h"
#include "RiaPreferences.h" #include "RiaPreferences.h"
#include "RiaProjectModifier.h" #include "RiaProjectModifier.h"
#include "RiaRegressionTest.h"
#include "RiaSocketServer.h" #include "RiaSocketServer.h"
#include "RiaVersionInfo.h" #include "RiaVersionInfo.h"
#include "RiaViewRedrawScheduler.h" #include "RiaViewRedrawScheduler.h"
@ -1994,6 +1995,18 @@ void RiaApplication::runRegressionTest(const QString& testRootPath, QStringList*
{ {
m_runningRegressionTests = true; m_runningRegressionTests = true;
RiaRegressionTest regressionTestConfig;
regressionTestConfig.readSettingsFromApplicationStore();
QString currentApplicationPath = QDir::currentPath();
if (!regressionTestConfig.folderContainingCompareTool().isEmpty())
{
// Windows Only : The image compare tool requires current working directory to be at the folder
// containing the image compare tool
QDir::setCurrent(regressionTestConfig.folderContainingCompareTool());
}
QString generatedFolderName = RegTestNames::generatedFolderName; QString generatedFolderName = RegTestNames::generatedFolderName;
QString diffFolderName = RegTestNames::diffFolderName; QString diffFolderName = RegTestNames::diffFolderName;
QString baseFolderName = RegTestNames::baseFolderName; QString baseFolderName = RegTestNames::baseFolderName;
@ -2189,6 +2202,8 @@ void RiaApplication::runRegressionTest(const QString& testRootPath, QStringList*
RiaLogging::info("\n"); RiaLogging::info("\n");
logInfoTextWithTimeInSeconds(timeStamp, "Completed regression tests"); logInfoTextWithTimeInSeconds(timeStamp, "Completed regression tests");
QDir::setCurrent(currentApplicationPath);
m_runningRegressionTests = false; m_runningRegressionTests = false;
} }
@ -2449,6 +2464,20 @@ void RiaApplication::executeRegressionTests(const QString& regressionTestPath, Q
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::executeRegressionTests()
{
RiaRegressionTest testConfig;
testConfig.readSettingsFromApplicationStore();
QString testPath = testConfig.regressionTestFolder();
QStringList testFilter = testConfig.testFilter().split(";", QString::SkipEmptyParts);
executeRegressionTests(testPath, &testFilter);
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -99,6 +99,7 @@ public:
bool parseArguments(); bool parseArguments();
void executeRegressionTests(const QString& regressionTestPath, QStringList* testFilter = nullptr); void executeRegressionTests(const QString& regressionTestPath, QStringList* testFilter = nullptr);
void executeRegressionTests();
void setActiveReservoirView(Rim3dView*); void setActiveReservoirView(Rim3dView*);
Rim3dView* activeReservoirView(); Rim3dView* activeReservoirView();

View File

@ -30,8 +30,8 @@ CAF_PDM_SOURCE_INIT(RiaRegressionTest, "RiaRegressionTest");
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiaRegressionTest::RiaRegressionTest(void) RiaRegressionTest::RiaRegressionTest(void)
{ {
CAF_PDM_InitFieldNoDefault(&applicationWorkingFolder, "workingFolder", "Folder containing <b>compare</b>", "", "Location of compare tool from Image Magic suite", ""); CAF_PDM_InitFieldNoDefault(&folderContainingCompareTool, "workingFolder", "Folder containing <b>compare</b>", "", "Location of compare tool from Image Magic suite", "");
applicationWorkingFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); folderContainingCompareTool.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&regressionTestFolder, "regressionTestFolder", "Regression Test Folder", "", "", ""); CAF_PDM_InitFieldNoDefault(&regressionTestFolder, "regressionTestFolder", "Regression Test Folder", "", "", "");
regressionTestFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); regressionTestFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
@ -71,7 +71,7 @@ void RiaRegressionTest::readSettingsFromApplicationStore()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiaRegressionTest::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) void RiaRegressionTest::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
{ {
if (field == &applicationWorkingFolder || field == &regressionTestFolder) if (field == &folderContainingCompareTool || field == &regressionTestFolder)
{ {
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>(attribute); caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr) if (myAttr)

View File

@ -36,7 +36,7 @@ public:
void readSettingsFromApplicationStore(); void readSettingsFromApplicationStore();
public: public:
caf::PdmField<QString> applicationWorkingFolder; caf::PdmField<QString> folderContainingCompareTool;
caf::PdmField<QString> regressionTestFolder; caf::PdmField<QString> regressionTestFolder;
caf::PdmField<QString> testFilter; caf::PdmField<QString> testFilter;
caf::PdmField<bool> showInteractiveDiffImages; caf::PdmField<bool> showInteractiveDiffImages;

View File

@ -41,14 +41,7 @@ bool RicLaunchRegressionTestsFeature::isCommandEnabled()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicLaunchRegressionTestsFeature::onActionTriggered(bool isChecked) void RicLaunchRegressionTestsFeature::onActionTriggered(bool isChecked)
{ {
RiaRegressionTest regTestConfig; RiaApplication::instance()->executeRegressionTests();
caf::PdmSettings::readFieldsFromApplicationStore(&regTestConfig);
QStringList testFilter = regTestConfig.testFilter().split(";", QString::SkipEmptyParts);
// Launch regression test using the current test folder and test filter
RiaApplication::instance()->executeRegressionTests(regTestConfig.regressionTestFolder, &testFilter);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -1726,16 +1726,8 @@ void RiuMainWindow::slotShowRegressionTestDialog()
// Write preferences using QSettings and apply them to the application // Write preferences using QSettings and apply them to the application
regTestConfig.writeSettingsToApplicationStore(); regTestConfig.writeSettingsToApplicationStore();
QString currentApplicationPath = QDir::currentPath();
QDir::setCurrent(regTestConfig.applicationWorkingFolder);
QStringList testFilter = regTestConfig.testFilter().split(";", QString::SkipEmptyParts);
RiaApplication* app = RiaApplication::instance(); RiaApplication* app = RiaApplication::instance();
app->executeRegressionTests(regTestConfig.regressionTestFolder, &testFilter); app->executeRegressionTests();
QDir::setCurrent(currentApplicationPath);
} }
} }