Skip to content

Commit

Permalink
Merge pull request #703 from neutronimaging/issue680_fixtestpath
Browse files Browse the repository at this point in the history
Issue680 fixtestpath
  • Loading branch information
anderskaestner authored Jun 26, 2024
2 parents 0873e65 + c0129a1 commit 71c5e2e
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ private Q_SLOTS:
TestImagingAlgorithms::TestImagingAlgorithms()
{
dataPath = QT_TESTCASE_BUILDDIR;
dataPath = dataPath + "/../../../../../TestData/";
#ifdef __APPLE__
dataPath = dataPath + "/../../../../../../TestData/";
#elif defined(__linux__)
dataPath = dataPath + "/../../../../../../TestData/";
#else
dataPath = dataPath + "/../../../../../TestData/";
#endif

kipl::strings::filenames::CheckPathSlashes(dataPath,true);

std::string fname = dataPath+"2D/tiff/spots/balls.tif";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ private Q_SLOTS:
TImagingQAAlgorithmsTest::TImagingQAAlgorithmsTest()
{
data_path = QT_TESTCASE_BUILDDIR;
data_path = data_path + "/../../../../../TestData/";
#ifdef __APPLE__
data_path = data_path + "/../../../../../../TestData/";
#elif defined(__linux__)
data_path = data_path + "/../../../../../../TestData/";
#else
data_path = data_path + "/../../../../../TestData/";
#endif
kipl::strings::filenames::CheckPathSlashes(data_path,true);
}

Expand Down
9 changes: 8 additions & 1 deletion core/kipl/UnitTests/tKIPL_IO/tst_kipl_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ private Q_SLOTS:
tKIPL_IOTest::tKIPL_IOTest()
{
data_path = QT_TESTCASE_BUILDDIR;
data_path = data_path + "/../../../../../TestData/";
#ifdef __APPLE__
data_path = data_path + "/../../../../../../TestData/";
#elif defined(__linux__)
data_path = data_path + "/../../../../../../TestData/";
#else
data_path = data_path + "/../../../../../TestData/";
#endif

kipl::strings::filenames::CheckPathSlashes(data_path,true);
}

Expand Down
8 changes: 7 additions & 1 deletion core/kipl/UnitTests/tKiplMath/tst_tkiplmathtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ TKiplMathTest::TKiplMathTest()
sin2D=img;

data_path = QT_TESTCASE_BUILDDIR;
data_path = data_path + "/../../../../../TestData/";
#ifdef __APPLE__
data_path = data_path + "/../../../../../../TestData/";
#elif defined(__linux__)
data_path = data_path + "/../../../../../../TestData/";
#else
data_path = data_path + "/../../../../../TestData/";
#endif
kipl::strings::filenames::CheckPathSlashes(data_path,true);
}

Expand Down
9 changes: 8 additions & 1 deletion core/kipl/UnitTests/tkiplbasetest/tst_kiplbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ private Q_SLOTS:
Tkiplbase::Tkiplbase()
{
data_path = QT_TESTCASE_BUILDDIR;
data_path = data_path + "/../../../../../TestData/";

#ifdef __APPLE__
data_path = data_path + "/../../../../../../TestData/";
#elif defined(__linux__)
data_path = data_path + "/../../../../../../TestData/";
#else
data_path = data_path + "/../../../../../TestData/";
#endif
kipl::strings::filenames::CheckPathSlashes(data_path,true);
}

Expand Down
8 changes: 7 additions & 1 deletion core/kipl/UnitTests/tkiplfilters/tst_kiplfilters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ private slots:
KiplFilters::KiplFilters()
{
dataPath = QT_TESTCASE_BUILDDIR;
dataPath = dataPath + "/../../../../../TestData/";
#ifdef __APPLE__
dataPath = dataPath + "/../../../../../../TestData/";
#elif defined(__linux__)
dataPath = dataPath + "/../../../../../../TestData/";
#else
dataPath = dataPath + "/../../../../../TestData/";
#endif
kipl::strings::filenames::CheckPathSlashes(dataPath,true);


Expand Down
5 changes: 3 additions & 2 deletions core/modules/ModuleConfig/src/modulelibnamemanger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ std::string ModuleLibNameManger::stripLinuxLibName(const std::string &path)
{
std::ostringstream msg;

if (!libInAppPath(path,m_sApplicationPath.substr(0,m_sApplicationPath.size()-4)+"Frameworks/") &&
!libInAppPath(path,m_sApplicationPath+"../Frameworks/") )

if (!libInAppPath(path,m_sApplicationPath.substr(0,m_sApplicationPath.size()-4)+"/lib") &&
!libInAppPath(path,m_sApplicationPath+"../lib/") )
{
msg << path.c_str()<<" is not in lib path";
logger.verbose(msg.str());
Expand Down
12 changes: 6 additions & 6 deletions core/modules/UnitTests/tModuleConfig/tst_configbasetest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,17 @@ void ConfigBaseTest::testLibNameManagerLinux()

ModuleLibNameManger mlnm(appPath);

QCOMPARE(mlnm.stripLibName(modulePath,kipl::base::OSLinux),std::string("StdBackProjectors"));

// qDebug() << mlnm.stripLibName(modulePath3,kipl::base::OSLinux).c_str() <<", "<< std::string("StdBackProjectors").c_str();
QCOMPARE(mlnm.stripLibName(modulePath3,kipl::base::OSLinux),std::string("StdBackProjectors"));

QCOMPARE(mlnm.generateLibName("StdBackProjectors",kipl::base::OSLinux),modulePath);

std::string modulePath2 = "../build-imagingsuite/Release/lib/libStdBackProjectors.so";
// This is a repeat of the above test
// std::string modulePath2 = "../build-imagingsuite/Release/lib/libStdBackProjectors.so";

QCOMPARE(mlnm.stripLibName(modulePath2,kipl::base::OSLinux),modulePath2);
// QCOMPARE(mlnm.stripLibName(modulePath2,kipl::base::OSLinux),modulePath2);

QCOMPARE(mlnm.generateLibName(modulePath2,kipl::base::OSLinux),modulePath2);
// QCOMPARE(mlnm.generateLibName(modulePath2,kipl::base::OSLinux),modulePath2);
}

void ConfigBaseTest::testLibNameManagerWindows()
Expand Down
12 changes: 10 additions & 2 deletions core/modules/UnitTests/tReaderConfig/tst_treaderconfigtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,18 @@ void TReaderConfigTest::testCreateDirectories()
{
// void CheckFolders(const std::string &path, bool create);


std::string path1 = "a/b/c";
kipl::strings::filenames::CheckPathSlashes(path1,false);
try {
std::filesystem::remove_all(path1);
}
catch (std::filesystem::filesystem_error &e)
{
qDebug() << e.what();
}

QVERIFY_THROWS_EXCEPTION(ReaderException,{ CheckFolders(path1,true); });
QVERIFY_THROWS_EXCEPTION(ReaderException,{ CheckFolders(path1,false); });
CheckFolders(path1,true);
QVERIFY(fs::is_directory(path1));

Expand All @@ -370,7 +378,7 @@ void TReaderConfigTest::testCreateDirectories()
fs::remove_all("a");

std::string path2 = "a2/b/c/";
kipl::strings::filenames::CheckPathSlashes(path2,false);
kipl::strings::filenames::CheckPathSlashes(path2,true);
CheckFolders(path2,true);
QVERIFY(fs::is_directory(path2));
fs::remove_all("a2");
Expand Down

0 comments on commit 71c5e2e

Please sign in to comment.