templates: also search in .config/syncevolution-templates (MBC #1208)
With this patch, template files are also found in .config/syncevolution-templates (or the corresponding directory pointed to by the XDG env variables). The tests had to be adapted a) to not find templates installed by the user in his own home and b) to cover finding templates via XDG_CONFIG_HOME.
This commit is contained in:
parent
29e0b8eac1
commit
8e759d4d59
|
@ -1519,6 +1519,7 @@ class CmdlineTest : public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testPrintServers);
|
||||
CPPUNIT_TEST(testPrintConfig);
|
||||
CPPUNIT_TEST(testPrintFileTemplates);
|
||||
CPPUNIT_TEST(testPrintFileTemplatesConfig);
|
||||
CPPUNIT_TEST(testTemplate);
|
||||
CPPUNIT_TEST(testMatchTemplate);
|
||||
CPPUNIT_TEST(testAddSource);
|
||||
|
@ -1852,6 +1853,7 @@ protected:
|
|||
|
||||
void testMatchTemplate() {
|
||||
ScopedEnvChange templates("SYNCEVOLUTION_TEMPLATE_DIR", "testcases/templates");
|
||||
ScopedEnvChange xdg("XDG_CONFIG_HOME", "/dev/null");
|
||||
|
||||
TestCmdline help1("--template", "?nokia 7210c", NULL);
|
||||
help1.doit();
|
||||
|
@ -2083,12 +2085,27 @@ protected:
|
|||
}
|
||||
|
||||
void testPrintFileTemplates() {
|
||||
rm_r(m_testDir);
|
||||
// use local copy of templates in build dir (no need to install)
|
||||
ScopedEnvChange templates("SYNCEVOLUTION_TEMPLATE_DIR", "./templates");
|
||||
ScopedEnvChange xdg("XDG_CONFIG_HOME", m_testDir);
|
||||
ScopedEnvChange home("HOME", m_testDir);
|
||||
|
||||
doPrintFileTemplates();
|
||||
}
|
||||
|
||||
void testPrintFileTemplatesConfig() {
|
||||
rm_r(m_testDir);
|
||||
mkdir_p(m_testDir);
|
||||
symlink("../templates", (m_testDir + "/syncevolution-templates").c_str());
|
||||
ScopedEnvChange templates("SYNCEVOLUTION_TEMPLATE_DIR", "/dev/null");
|
||||
ScopedEnvChange xdg("XDG_CONFIG_HOME", m_testDir);
|
||||
ScopedEnvChange home("HOME", m_testDir);
|
||||
|
||||
doPrintFileTemplates();
|
||||
}
|
||||
|
||||
void doPrintFileTemplates() {
|
||||
testSetupFunambol();
|
||||
|
||||
{
|
||||
|
|
|
@ -418,7 +418,9 @@ SyncConfig::TemplateList SyncConfig::matchPeerTemplates(const DeviceList &peers,
|
|||
string templateDir(SyncEvolutionTemplateDir());
|
||||
std::queue <std::string, std::list<std::string> > directories;
|
||||
|
||||
directories.push (templateDir);
|
||||
directories.push(templateDir);
|
||||
templateDir = SubstEnvironment("${XDG_CONFIG_HOME}/syncevolution-templates");
|
||||
directories.push(templateDir);
|
||||
while (!directories.empty()) {
|
||||
string sDir = directories.front();
|
||||
directories.pop();
|
||||
|
|
Loading…
Reference in New Issue