Skip to content
Snippets Groups Projects
Commit 7fb3d6ff authored by Nick Draper's avatar Nick Draper
Browse files

re #10489_instrument_directories

parent f74b812a
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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;
......
......@@ -187,6 +187,46 @@ 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
std::cout<<std::endl<<directories[0]<<std::endl;
std::cout<<std::endl<<ConfigService::Instance().getAppDataDir()<<std::endl;
std::cout<<std::endl<<directories[0].find("instruxxment")<<std::endl;
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()
......
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