Unit-testing of GHC code

Jan Stolarek jan.stolarek at p.lodz.pl
Fri Aug 2 17:31:49 CEST 2013

Thank you Ian - this indeed does the trick. But going a bit further I've encountered another problem. I need to run my computations in the Ghc session, because otherwise some actions fail with panic:

CmmCopyPropagationTest: CmmCopyPropagationTest: panic! (the 'impossible' happened)
  (GHC version 7.7.20130731 for i386-unknown-linux):
        v_unsafeGlobalDynFlags: not initialised

My understanding is that I can use runGhc function from Ghc module to run actions in Ghc monad and lift the result to IO monad. I'm having problems with the second paramter to runGhc function. Is there a robust way of obtaining that parameter so that the test is portable across machines (I want to make that test a part of the testsuite)?


----- Oryginalna wiadomość -----
Od: "Ian Lynagh" <ian at well-typed.com>
Do: "Jan Stolarek" <jan.stolarek at p.lodz.pl>
DW: "ghc-devs" <ghc-devs at haskell.org>
Wysłane: środa, 31 lipiec 2013 20:07:42
Temat: Re: Unit-testing of GHC code

On Wed, Jul 31, 2013 at 04:10:46PM +0200, Jan Stolarek wrote:
> and so on (Hunit would only be a convenient interface here). The question is how can I import a GHC module from within the testsuite and call its functions to test it they behave propertly? An attempt to simply import the module results in compilation error:
>     Failed to load interface for ‛Foo’
>     It is a member of the hidden package ‛ghc-7.7.20130731’.
>     Use -v to see a list of the files searched for.
> Is there a workaround for this?

You need to use "-package ghc" if you want to use the GHC API.

Ian Lynagh, Haskell Consultant
Well-Typed LLP, http://www.well-typed.com/

More information about the ghc-devs mailing list