Unit tests for GHC code?

Joachim Breitner mail at joachim-breitner.de
Wed Jan 29 09:58:08 UTC 2014


Hi,

I am currently working on a piece of code (an analysis to solve #7994)
where I’d like to make sure that my changes do not regress over what I
had before. But I find it unnecessarily hard to write our usual
test-case styles for them:
      * I’d like to test against very small Core that does not involve
        anything unnecessary. But it is hard to write Haskell that has,
        when it hits my analysis, this shape. It requires lots of {-#
        NOINLINE #-} and other tricks.
      * To test the result, I either have to write a performance test,
        but it is not always easy to come up with a program where the
        gains are massive enough to become a reliable test. It is
        possible, but work, and doing it maybe half a dozen times for
        various inputs is tricky.
      * Alternative, I can dump the Core and add that to the test cases.
        But now other changes to the compiler can easily trigger my test
        case failing.

So I thought about writing a test case that simply imports my module
from the ghc library, generates artificial, minimal core, and checks the
output for precisely what I want (in my case, some fields of the IdInfo
of various binders).

I don’t see any examples for that in the test suite. Is that just
because noone has done that before, or is there inherently bad about
this approach that we do _not_ want to that?

Also, we don’t have a parser for Core, so I’ll have to build my syntax
trees using the stuff from MkCore et al, right?

Thanks,
Joachim


-- 
Joachim “nomeata” Breitner
  mail at joachim-breitner.dehttp://www.joachim-breitner.de/
  Jabber: nomeata at joachim-breitner.de  • GPG-Key: 0x4743206C
  Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20140129/7c9bd9cb/attachment.sig>


More information about the ghc-devs mailing list