#2554 Regression Test : Detect command files and execute content

This commit is contained in:
Magne Sjaastad 2018-03-06 11:56:32 +01:00
parent b2204fb22a
commit ce2b4febbb

View File

@ -164,6 +164,7 @@ namespace RegTestNames
const QString testFolderFilter = "TestCase*";
const QString imageCompareExeName = "compare";
const QString reportFileName = "ResInsightRegressionTestReport.html";
const QString commandFileFilter = "commandfile-*";
};
@ -1998,7 +1999,6 @@ void RiaApplication::runRegressionTest(const QString& testRootPath, QStringList*
QString baseFolderName = RegTestNames::baseFolderName;
QString regTestProjectName = RegTestNames::testProjectName;
QString regTestFolderFilter = RegTestNames::testFolderFilter;
// Find all sub folders
QDir testDir(testRootPath); // If string is empty it will end up as cwd
@ -2091,6 +2091,39 @@ void RiaApplication::runRegressionTest(const QString& testRootPath, QStringList*
{
QDir testCaseFolder(folderList[dirIdx].filePath());
// Detect any command files
QStringList filterList;
filterList << RegTestNames::commandFileFilter;
QFileInfoList commandFileEntries = testCaseFolder.entryInfoList(filterList);
if (!commandFileEntries.empty())
{
QString currentApplicationPath = QDir::current().absolutePath();
// Set current path to the folder containing the command file, as this is required when using file references
// in the command file
QDir::setCurrent(folderList[dirIdx].filePath());
for (const auto& fileInfo : commandFileEntries)
{
QString commandFile = fileInfo.absoluteFilePath();
QFile file(commandFile);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
RiaLogging::error("Failed to open command file : " + commandFile);
}
else
{
QTextStream in(&file);
RicfCommandFileExecutor::instance()->executeCommands(in);
}
}
QDir::setCurrent(currentApplicationPath);
}
QString projectFileName;
if (testCaseFolder.exists(regTestProjectName + ".rip"))