Skip to content

Commit

Permalink
Merge branch 'feature/10489_instrument_directories' of github.com:man…
Browse files Browse the repository at this point in the history
…tidproject/mantid into feature/10489_instrument_directories
  • Loading branch information
NickDraper committed Nov 6, 2014
2 parents da59d5b + 3ecb540 commit 07ec05c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Kernel/CMakeLists.txt
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Code/Mantid/Framework/Kernel/src/ConfigService.cpp
Expand Up @@ -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;
Expand Down
37 changes: 37 additions & 0 deletions Code/Mantid/Framework/Kernel/test/ConfigServiceTest.h
Expand Up @@ -187,6 +187,43 @@ class ConfigServiceTest : public CxxTest::TestSuite
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()
Expand Down
Expand Up @@ -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")
Expand Down

0 comments on commit 07ec05c

Please sign in to comment.