diff --git a/Code/Mantid/Framework/Kernel/CMakeLists.txt b/Code/Mantid/Framework/Kernel/CMakeLists.txt index 2a662b61e67ff463f39b7c3d4096b75f5b607563..eb69cdb6b0b683733d014cc96952e1b62144e511 100644 --- a/Code/Mantid/Framework/Kernel/CMakeLists.txt +++ b/Code/Mantid/Framework/Kernel/CMakeLists.txt @@ -364,7 +364,7 @@ set_property ( TARGET Kernel PROPERTY FOLDER "MantidFramework" ) target_link_libraries ( Kernel ${MANTIDLIBS} ${GSL_LIBRARIES} ${NEXUS_LIBRARIES} ) if ( WIN32 ) - target_link_libraries ( Kernel Psapi.lib shell32.lib ) # For memory usage queries + target_link_libraries ( Kernel Psapi.lib ) # For memory usage queries endif() # Add the unit tests directory diff --git a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp index c0d1aebf3c0081f386cce5c06836f5616e858c22..45dfdba5c7ae5f93e20ba4dfc0977aa4e4bea395 100644 --- a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp +++ b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp @@ -1607,6 +1607,11 @@ bool ConfigServiceImpl::addDirectoryifExists(const std::string& directoryName, s } } catch (Poco::PathNotFoundException&) + { + g_log.information("Unable to locate directory at: " + directoryName); + return false; + } + catch (Poco::FileNotFoundException&) { g_log.information("Unable to locate directory at: " + directoryName); return false; diff --git a/Code/Mantid/Framework/Kernel/test/ConfigServiceTest.h b/Code/Mantid/Framework/Kernel/test/ConfigServiceTest.h index 5af09a06f0089a3426c44e6b2f350038e6a89262..7ecea0ac03a265c206105d899a080402d4af240c 100644 --- a/Code/Mantid/Framework/Kernel/test/ConfigServiceTest.h +++ b/Code/Mantid/Framework/Kernel/test/ConfigServiceTest.h @@ -187,6 +187,43 @@ public: TS_ASSERT_LESS_THAN(0, ConfigService::Instance().getCurrentDir().length()); //check that the string is not empty // TS_ASSERT_LESS_THAN(0, ConfigService::Instance().getHomeDir().length()); //check that the string is not empty TS_ASSERT_LESS_THAN(0, ConfigService::Instance().getTempDir().length()); //check that the string is not empty + + std::string appdataDir = ConfigService::Instance().getAppDataDir(); + TS_ASSERT_LESS_THAN(0, appdataDir.length()); +#ifdef _WIN32 + std::string::size_type index = appdataDir.find("\\AppData\\Roaming\\mantidproject\\mantid"); + TSM_ASSERT_LESS_THAN("Could not find correct path in getAppDataDir()",index,appdataDir.size()); +#else + std::string::size_type index = appdataDir.find("/.mantid"); + TSM_ASSERT_LESS_THAN("Could not find correct path in getAppDataDir()",index,appdataDir.size()); +#endif + + } + + void TestInstrumentDirectory() + { + + auto directories = ConfigService::Instance().getInstrumentDirectories(); + TS_ASSERT_LESS_THAN(1,directories.size()); + //the first entry should be the AppDataDir + instrument + TSM_ASSERT_LESS_THAN("Could not find the appData directory in getInstrumentDirectories()[0]",directories[0].find(ConfigService::Instance().getAppDataDir()),directories[0].size()); + TSM_ASSERT_LESS_THAN("Could not find the 'instrument' directory in getInstrumentDirectories()[0]",directories[0].find("instrument"),directories[0].size()); + + if (directories.size() == 3) + { + // The middle entry should be /etc/mantid/instrument + TSM_ASSERT_LESS_THAN("Could not find /etc/mantid/instrument path in getInstrumentDirectories()[1]",directories[1].find("etc/mantid/instrument"),directories[1].size()); + } + //Check that the last directory matches that returned by getInstrumentDirectory + TS_ASSERT_EQUALS(directories[directories.size()-1],ConfigService::Instance().getInstrumentDirectory()); + + //check all of the directory entries actually exist + for (auto it = directories.begin(); it != directories.end(); ++it) + { + Poco::File directory(*it); + TSM_ASSERT(*it + " does not exist", directory.exists()); + } + } void TestCustomProperty() diff --git a/Code/Mantid/Framework/PythonInterface/mantid/kernel/src/Exports/ConfigService.cpp b/Code/Mantid/Framework/PythonInterface/mantid/kernel/src/Exports/ConfigService.cpp index 7377bf3e03662e2c7a59c985ed950cf8a6806901..762f446435d56a3f2bad87ec96e4bccaf5a7481d 100644 --- a/Code/Mantid/Framework/PythonInterface/mantid/kernel/src/Exports/ConfigService.cpp +++ b/Code/Mantid/Framework/PythonInterface/mantid/kernel/src/Exports/ConfigService.cpp @@ -53,6 +53,9 @@ void export_ConfigService() .def("getInstrumentDirectory", &ConfigServiceImpl::getInstrumentDirectory, "Returns the directory used for the instrument definitions") + .def("getInstrumentDirectories", &ConfigServiceImpl::getInstrumentDirectories, return_value_policy<reference_existing_object>(), + "Returns the list of directories searched for the instrument definitions") + .def("getFacilityNames", &ConfigServiceImpl::getFacilityNames, "Returns the default facility") .def("getFacilities", &ConfigServiceImpl::getFacilities, "Returns the default facility")