[cfe-dev] unit tests for Clang TDD
Chandler Carruth
chandlerc at google.com
Sat Oct 15 01:10:07 PDT 2011
On Sat, Oct 15, 2011 at 12:34 AM, David Kristola <kristol1 at illinois.edu>wrote:
> I am working on some new static analysis capabilities for a class
> project (new for C/C++, derived from an existing Java tool). While
> making a contribution to the Clang code base isn't required for the
> class, it is a goal.
>
> Now that I have a copy of LLVM and Clang source code downloaded,
> compiled, and the regression test suite running, i am looking at how to
> set up my own tests. When the documentation used the term "regression"
> for the test suite, it was accurate. The test suite is a nice
> integration-level set of tests.
>
> But what about unit-level tests? Did i miss something in the
> documentation or directory tree? Is there a preferred unit test
> framework? I don't want to start coding until i have a failing unit
> test in place.
>
There is a top-level directory in the Clang tree "unittests". It has several
tests under it, using the Google Test framework. Currently, the static
analyzer doesn't get a lot of unit testing, but there are certainly many
parts of it where that would make sense (things like abstract graph
algorithms, etc.).
That said, there is more emphasis on somewhat mid-level integration testing
in Clang. The tools are architected in a way to facilitate remarkably
targeted "regression" tests that focus on a specific piece of functionality.
Specifically with the analyzer, usually you can craft a minimal test case
which should exhibit a very specific static analysis report. These test
cases can be extremely minimal and focused in order to ensure reasonable
debugging and targeting of any failures.
Unit tests are often reserved for parts of Clang which don't lend themselves
to this, due to abstract functional behavior, etc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111015/656a83bf/attachment.html>
More information about the cfe-dev
mailing list