summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2011-10-16 12:29:50 +0000
committerPatrick Ohly <patrick.ohly@intel.com>2011-10-17 08:42:54 +0000
commit3f37dbe84ec24edbf8be5004391f1467dd05200c (patch)
treeaea23b0ba1ae3fcc427e182e804cd5ddecf5f725
parent3789bc9eb82c3559d1510cf705d8b1268979207b (diff)
testing: avoid anchor dependencies between tests
TestingSyncSourcePtr manages anchors for all sources created via it. These anchors used to be reused when running multiple tests, which may have led to different results compared to running tests by themselves. So now the anchors get reset at the start of each test, detected by the changed getCurrentTest() name. This change was triggered by the observation that combining Client::Sync::eds_event::testItems with Client::Source::google_caldav failed in Client::Source::google_caldav::testChanges around change tracking. The reason was that the anchor for an EDS source in eds_event::testItems was reused as the anchor for a CalDAV source in google_caldav::testChanges, which prevented a slow item scan when it would have been needed.
-rw-r--r--test/ClientTest.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ClientTest.cpp b/test/ClientTest.cpp
index 63507b0b..b5dd8cb4 100644
--- a/test/ClientTest.cpp
+++ b/test/ClientTest.cpp
@@ -133,12 +133,21 @@ class TestingSyncSourcePtr : public std::auto_ptr<TestingSyncSource>
typedef std::auto_ptr<TestingSyncSource> base_t;
static StringMap m_anchors;
+ static std::string m_testName;
public:
TestingSyncSourcePtr() {}
TestingSyncSourcePtr(TestingSyncSource *source) :
base_t(source)
{
+ // reset anchors each time a new test starts,
+ // because it avoids interactions between tests
+ std::string testName = getCurrentTest();
+ if (testName != m_testName) {
+ m_anchors.clear();
+ m_testName = testName;
+ }
+
CPPUNIT_ASSERT(source);
source->open();
string node = source->getTrackingNode()->getName();
@@ -180,6 +189,7 @@ public:
};
StringMap TestingSyncSourcePtr::m_anchors;
+std::string TestingSyncSourcePtr::m_testName;
bool SyncOptions::defaultWBXML()
{