mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#6765 Test System : Add flag from regression dialog to invalidate external files
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaProjectModifier::RiaProjectModifier()
|
||||
: m_invalidateExternalPaths( false )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -95,6 +96,28 @@ void RiaProjectModifier::setReplacePropertiesFolder( int caseIdToReplace, QStrin
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaProjectModifier::setInvalidateExternalPaths()
|
||||
{
|
||||
m_invalidateExternalPaths = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaProjectModifier::invalidateExternalPaths( RimProject* project )
|
||||
{
|
||||
std::vector<caf::FilePath*> filePaths = project->allFilePaths();
|
||||
|
||||
const QString invalidPath = "path_does_not_exist";
|
||||
for ( caf::FilePath* filePath : filePaths )
|
||||
{
|
||||
filePath->setPath( invalidPath );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -115,6 +138,11 @@ bool RiaProjectModifier::applyModificationsToProject( RimProject* project )
|
||||
replacePropertiesFolder( project );
|
||||
}
|
||||
|
||||
if ( m_invalidateExternalPaths )
|
||||
{
|
||||
invalidateExternalPaths( project );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,12 +47,17 @@ public:
|
||||
void setReplacePropertiesFolderFirstOccurrence( QString newPropertiesFolder );
|
||||
void setReplacePropertiesFolder( int caseIdToReplace, QString newPropertiesFolder );
|
||||
|
||||
// Used by the regression test system to invalidate all paths to test if the tests run as expected if external files
|
||||
// are missing/invalid
|
||||
void setInvalidateExternalPaths();
|
||||
|
||||
bool applyModificationsToProject( RimProject* project );
|
||||
|
||||
private:
|
||||
void replaceSourceCases( RimProject* project );
|
||||
void replaceCase( RimProject* project );
|
||||
void replacePropertiesFolder( RimProject* project );
|
||||
void invalidateExternalPaths( RimProject* project );
|
||||
|
||||
static QString makeFilePathAbsolute( const QString& relOrAbsolutePath );
|
||||
static QString caseNameFromGridFileName( const QString& fullGridFilePathName );
|
||||
@@ -67,4 +72,5 @@ private:
|
||||
std::map<int, QString> m_caseIdToGridFileNameMap;
|
||||
std::map<int, std::vector<QString>> m_groupIdToGridFileNamesMap;
|
||||
std::map<int, QString> m_caseIdToPropertiesFolderMap;
|
||||
bool m_invalidateExternalPaths;
|
||||
};
|
||||
|
||||
@@ -83,6 +83,14 @@ RiaRegressionTest::RiaRegressionTest( void )
|
||||
"",
|
||||
"",
|
||||
"" );
|
||||
|
||||
CAF_PDM_InitField( &makeExternalIncludePathsInvalid,
|
||||
"makeExternalIncludePathsInvalid",
|
||||
false,
|
||||
"Invalidate all External Paths",
|
||||
"",
|
||||
"",
|
||||
"" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
caf::PdmField<bool> useOpenMPForGeometryCreation;
|
||||
caf::PdmField<bool> openReportInBrowser;
|
||||
caf::PdmField<bool> appendTestsAfterTestFilter;
|
||||
caf::PdmField<bool> makeExternalIncludePathsInvalid;
|
||||
|
||||
protected:
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "RiaImageCompareReporter.h"
|
||||
#include "RiaImageFileCompare.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaProjectModifier.h"
|
||||
#include "RiaRegressionTest.h"
|
||||
#include "RiaTextFileCompare.h"
|
||||
|
||||
@@ -194,9 +195,17 @@ void RiaRegressionTestRunner::runRegressionTest()
|
||||
|
||||
if ( !projectFileName.isEmpty() )
|
||||
{
|
||||
cvf::ref<RiaProjectModifier> projectModifier;
|
||||
if ( regressionTestConfig.makeExternalIncludePathsInvalid )
|
||||
{
|
||||
projectModifier = new RiaProjectModifier;
|
||||
projectModifier->setInvalidateExternalPaths();
|
||||
}
|
||||
logInfoTextWithTimeInSeconds( timeStamp, "Initializing test :" + testCaseFolder.absolutePath() );
|
||||
|
||||
app->loadProject( testCaseFolder.filePath( projectFileName ) );
|
||||
app->loadProject( testCaseFolder.filePath( projectFileName ),
|
||||
RiaApplication::ProjectLoadAction::PLA_NONE,
|
||||
projectModifier.p() );
|
||||
|
||||
// Wait until all command objects have completed
|
||||
app->waitUntilCommandObjectsHasBeenProcessed();
|
||||
|
||||
@@ -445,9 +445,7 @@ void RimProject::setProjectFileNameAndUpdateDependencies( const QString& project
|
||||
QFileInfo fileInfoOld( oldProjectFileName );
|
||||
QString oldProjectPath = fileInfoOld.path();
|
||||
|
||||
std::vector<caf::FilePath*> filePaths;
|
||||
fieldContentsByType( this, filePaths );
|
||||
|
||||
std::vector<caf::FilePath*> filePaths = allFilePaths();
|
||||
for ( caf::FilePath* filePath : filePaths )
|
||||
{
|
||||
bool foundFile = false;
|
||||
@@ -1342,6 +1340,17 @@ RimPlotTemplateFolderItem* RimProject::rootPlotTemlateItem() const
|
||||
return m_plotTemplateFolderItem;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<caf::FilePath*> RimProject::allFilePaths() const
|
||||
{
|
||||
std::vector<caf::FilePath*> filePaths;
|
||||
fieldContentsByType( this, filePaths );
|
||||
|
||||
return filePaths;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1629,9 +1638,7 @@ void RimProject::transferPathsToGlobalPathList()
|
||||
{
|
||||
GlobalPathListMapper pathListMapper( m_globalPathList() );
|
||||
|
||||
std::vector<caf::FilePath*> filePaths;
|
||||
fieldContentsByType( this, filePaths );
|
||||
|
||||
std::vector<caf::FilePath*> filePaths = allFilePaths();
|
||||
for ( caf::FilePath* filePath : filePaths )
|
||||
{
|
||||
QString path = filePath->path();
|
||||
@@ -1652,9 +1659,7 @@ void RimProject::distributePathsFromGlobalPathList()
|
||||
{
|
||||
GlobalPathListMapper pathListMapper( m_globalPathList() );
|
||||
|
||||
std::vector<caf::FilePath*> filePaths;
|
||||
fieldContentsByType( this, filePaths );
|
||||
|
||||
std::vector<caf::FilePath*> filePaths = allFilePaths();
|
||||
for ( caf::FilePath* filePath : filePaths )
|
||||
{
|
||||
QString pathIdCandidate = filePath->path().trimmed();
|
||||
|
||||
@@ -190,6 +190,8 @@ public:
|
||||
|
||||
RimPlotTemplateFolderItem* rootPlotTemlateItem() const;
|
||||
|
||||
std::vector<caf::FilePath*> allFilePaths() const;
|
||||
|
||||
protected:
|
||||
// Overridden methods
|
||||
void initAfterRead() override;
|
||||
@@ -199,7 +201,7 @@ protected:
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
void fieldContentsByType( caf::PdmObjectHandle* object, std::vector<T*>& fieldContents );
|
||||
static void fieldContentsByType( const caf::PdmObjectHandle* object, std::vector<T*>& fieldContents );
|
||||
|
||||
void transferPathsToGlobalPathList();
|
||||
void distributePathsFromGlobalPathList();
|
||||
@@ -233,7 +235,7 @@ private:
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void RimProject::fieldContentsByType( caf::PdmObjectHandle* object, std::vector<T*>& fieldContents )
|
||||
void RimProject::fieldContentsByType( const caf::PdmObjectHandle* object, std::vector<T*>& fieldContents )
|
||||
{
|
||||
if ( !object ) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user