Skip to content
Snippets Groups Projects
Commit 1227a332 authored by Jonathan Guinet's avatar Jonathan Guinet
Browse files

ENH: Baseline file extension checking mantis #ref 476 - JIRA OTB-120 SubTask

parent 227287aa
No related branches found
No related tags found
No related merge requests found
...@@ -1014,28 +1014,37 @@ std::map<std::string, int> TestHelper::RegressionTestBaselines(char *baselineFil ...@@ -1014,28 +1014,37 @@ std::map<std::string, int> TestHelper::RegressionTestBaselines(char *baselineFil
std::map<std::string, int> baselines; std::map<std::string, int> baselines;
baselines[std::string(baselineFilename)] = 0; baselines[std::string(baselineFilename)] = 0;
std::string myPath = itksys::SystemTools::GetFilenamePath( baselineFilename ); std::string myPath = itksys::SystemTools::GetFilenamePath(baselineFilename);
itksys::Directory myDir; itksys::Directory myDir;
myDir.Load( myPath.c_str() ); myDir.Load(myPath.c_str());
const unsigned int nbFiles = myDir.GetNumberOfFiles(); const unsigned int nbFiles = myDir.GetNumberOfFiles();
const std::string originalBaseline = itksys::SystemTools::GetFilenameWithoutLastExtension(baselineFilename); const std::string originalBaseline = itksys::SystemTools::GetFilenameWithoutLastExtension(baselineFilename);
const unsigned int sizeRef = originalBaseline.size(); const unsigned int sizeRef = originalBaseline.size();
const bool HasExtension = sizeRef != itksys::SystemTools::GetFilenameName(baselineFilename).size();
myPath.append("/"); myPath.append("/");
itksys::RegularExpression reg; itksys::RegularExpression reg;
reg.compile( "^\\.[0-9]"); reg.compile("^\\.[0-9]");
for(unsigned int i=0; i<nbFiles; i++) for (unsigned int i = 0; i < nbFiles; i++)
{ {
const std::string curFilename = itksys::SystemTools::GetFilenameWithoutLastExtension( myDir.GetFile( i ) ); std::string curFilename;
if (HasExtension)
if( curFilename.substr(0, sizeRef) == originalBaseline ) {
curFilename = itksys::SystemTools::GetFilenameWithoutLastExtension(myDir.GetFile(i));
}
else
{
curFilename = itksys::SystemTools::GetFilenameName(myDir.GetFile(i));
}
if (curFilename.substr(0, sizeRef) == originalBaseline)
{ {
if(reg.find( curFilename.substr(sizeRef, curFilename.size()))) if (reg.find(curFilename.substr(sizeRef, curFilename.size())))
{ {
std::string myFile = myPath; std::string myFile = myPath;
baselines[myFile.append(myDir.GetFile( i ) )] = 0; baselines[myFile.append(myDir.GetFile(i))] = 0;
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment