C++ duchain unit tests

Nicolás Alvarez nicolas.alvarez at gmail.com
Thu Jun 17 19:29:04 UTC 2010


I'm finding many problems with the duchaintest for C++. One was pretty
bad and fixed by Milian earlier today (a test was calling finalCleanup
and causing corrupted ASTs for every test that followed).

I just found another: testDeclareUsingNamespace fails if run alone.

FAIL!  : TestDUChain::testDeclareUsingNamespace() Compared values are
not the same
   Actual (bar->uses().count()): 0
   Expected (1): 1
   Loc: [kdevelop/languages/cpp/cppduchain/tests/test_duchain.cpp(2164)]

You can test this by passing the test function name as an argument to
the test tool:
./duchaintest.shell testDeclareUsingNamespace

The test works if testLocalNamespaceAlias runs before. I haven't
checked if only this particular test makes DeclareUsingNamespace pass,
or if there are others.

I modified testDeclareUsingNamespace to dump duchain, and when run
alone, the foo::bar declaration indeed has zero uses; while when run
after testLocalNamespaceAlias, there is a properly-ranged use.

>From looking at the tests alone, I can't figure out why it does work
if testLocalNamespaceAlias runs first. Isn't release(top) supposed to
cleanup enough? (I'm not yet planning to dive into the giant codebase
of the C++ parser :P)

-- 
Nicolas




More information about the KDevelop-devel mailing list