vm.insert CMAKE_CURRENT_SOURCE_DIR is needed since 953842
where a Q_ASSERT was added to make sure CMAKE_CURRENT_SOURCE_DIR is defined

addDocumentChain in testUses is needed to avoid assert indexed.data() == context
in removeDocumentChain that fires when a addDocumentChain was never called

addDocumentChain + removeDocumentChain testDUChainWalk
are needed to avoid assert m_recursiveImports.isEmpty()
in TopDUContextLocalPrivate::clearImportedContextsRecursively
---

I am no duchain/cmake expert, so please review carefully.
Also i don't know if addDocumentChain + removeDocumentChain
is the right cure for the m_recursiveImports.isEmpty() assert.

If it is, i plan to fix cmake_cmakeprojectvisitor_test.cpp the same way.
(it also triggers the m_recursiveImports.isEmpty() assert)

 projectmanagers/cmake/tests/cmakeduchaintest.cpp |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/projectmanagers/cmake/tests/cmakeduchaintest.cpp b/projectmanagers/cmake/tests/cmakeduchaintest.cpp
index 1b5f56f..ec0e625 100644
--- a/projectmanagers/cmake/tests/cmakeduchaintest.cpp
+++ b/projectmanagers/cmake/tests/cmakeduchaintest.cpp
@@ -83,6 +83,7 @@ void CMakeDUChainTest::testDUChainWalk()
     {
         DUChainWriteLocker lock(DUChain::lock());
         m_fakeContext = new TopDUContext(IndexedString("test"), SimpleRange(0,0,0,0));
+        DUChain::self()->addDocumentChain(m_fakeContext);
     }
     
     QFile file("cmake_duchain_test");
@@ -98,6 +99,7 @@ void CMakeDUChainTest::testDUChainWalk()
     MacroMap mm;
     VariableMap vm;
     CacheValues cv;
+    vm.insert("CMAKE_CURRENT_SOURCE_DIR", QStringList("."));
 
     CMakeProjectVisitor v(file.fileName(), m_fakeContext);
     v.setVariableMap(&vm);
@@ -135,6 +137,8 @@ void CMakeDUChainTest::testDUChainWalk()
             qDebug() << "doesn't exist " << sr.start.column << sr.end.column;
         QVERIFY(found);
     }
+    
+    DUChain::self()->removeDocumentChain(m_fakeContext);
 }
 
 void CMakeDUChainTest::testUses_data()
@@ -209,6 +213,7 @@ void CMakeDUChainTest::testUses()
         }
     }
     ReferencedTopDUContext m_fakeContext=new TopDUContext(IndexedString(file.fileName()), SimpleRange(0,0, endl, endc));
+    DUChain::self()->addDocumentChain(m_fakeContext);
     
     QString inputIncluded=
         "set(avalue 33)\n"
@@ -227,6 +232,7 @@ void CMakeDUChainTest::testUses()
     MacroMap mm;
     VariableMap vm;
     CacheValues cv;
+    vm.insert("CMAKE_CURRENT_SOURCE_DIR", QStringList("."));
 
     CMakeProjectVisitor v(file.fileName(), m_fakeContext);
     v.setVariableMap(&vm);
-- 
1.6.3.1



