[LLVMdev] Unit test patch, updated
Bill Wendling
isanbard at gmail.com
Thu Jan 1 04:08:05 PST 2009
On Jan 1, 2009, at 1:21 AM, Talin wrote:
> Hooray!
>
> I'm thinking that getting unit tests for the classes in ADT should
> be an
> early goal.
>
Definitely! This is an area of "low hanging fruit".
> I also wanted to mention a point about the general philosophy of unit
> testing, which is that the presence of such tests alters the
> calculation
> of risk when making changes to a code base. Programmers have various
> rules of thumb for estimating risk - for example, a change which
> affects
> a large number of lines of code is generally perceived to be riskier
> than a change which affects a small number of lines. But at the same
> time, some very large changes can carry almost no risk - such as
> changing the name of a symbol which occurs in thousands of places in
> the
> code - because the compiler will tell you if you made a mistake
> anywhere. What unit tests do is allow that same kind of assurance at
> the
> semantic level that the compiler's syntax checking gives you at the
> syntactical level. And since reduction of risk in one area allows
> taking
> greater risks elsewhere, it can act as an enabler for global
> refactorings and other radical improvements that would have been
> perceived as too risky otherwise.
>
> This ability of unit tests to reduce perceived risk works best if the
> tests are comprehensive, testing even trivial aspects of the target
> class (such as brand new container correctly reporting empty()).
>
I completely agree with all you said here. LLVM has been lacking in
"quality assurance" for a long time. Only recently have we've set up
buildbot systems to make sure that incremental changes won't break
obvious things. The unit testing will make sure that invariant
assumptions about the code will remain after each change. Those people
who maintain buildbot systems should add the unit tests as part of the
testing process.
Thanks for spearheading this, Talin!
-bw
More information about the llvm-dev
mailing list