
Hi, I'm writing a Cabal package, using main=defaultMain in Setup.hs. It has a library, and I want to also build a few executables so I can test the library. How am I supposed to do that? My attempt was to create 'executable' sections for those tests. However, I don't know how to include the main library in the modules used by those tests. I tried to insert my own package in a 'build-depends' line, but that didn't work. Thanks for your tips, Maurício

I'm writing a Cabal package, using main=defaultMain in Setup.hs. It has a library, and I want to also build a few executables so I can test the library. How am I supposed to do that? My attempt was to create 'executable' sections for those tests. However, I don't know how to include the main library in the modules used by those tests. I tried to insert my own package in a 'build-depends' line, but that didn't work.
You might consider looking at the EMGM cabal file in the source. https://svn.cs.uu.nl:12443/viewvc/dgp-haskell/EMGM/ There are some things in there that support building a 'test' executable for the library. Specifically, the flag "-ftest" builds the executable and enables its build-depends. Since the 'test' flag is false by default, those build-depends are not passed onto users who download EMGM from Hackage. Note that the way it's done, Cabal will build the library and the executable separately. From what I understand, there's no easy way to have an executable depend on a library in the same Cabal config file. So, you're actually building the library twice. We have a "-fnolib" flag for disabling the library build to speed things up. To get this, you'd use "-ftest -fnolib". If you want to support the 'test' argument to Cabal (e.g. "runhaskell Setup.lhs test" or "cabal test" using cabal-install), you can find that code in the Setup.lhs file from the source link above. Sean

I'm writing a Cabal package, using main=defaultMain in Setup.hs. It has a library, and I want to also build a few executables so I can test the library. How am I supposed to do that? (...)
You might consider looking at the EMGM cabal file in the source.
https://svn.cs.uu.nl:12443/viewvc/dgp-haskell/EMGM/
(...)
From the site: Échec de la connexion sécurisée svn.cs.uu.nl:12443 utilise un certificat de sécurité invalide. Le certificat n'est pas sûr car l'autorité délivrant le certificat est inconnue. (Code d'erreur : sec_error_unknown_issuer) The test argument to Setup seems nice. Is there some already defined on the hook for tests? Thanks, Maurício

You might consider looking at the EMGM cabal file in the source.
https://svn.cs.uu.nl:12443/viewvc/dgp-haskell/EMGM/
(...)
From the site:
Échec de la connexion sécurisée svn.cs.uu.nl:12443 utilise un certificat de sécurité invalide. Le certificat n'est pas sûr car l'autorité délivrant le certificat est inconnue. (Code d'erreur : sec_error_unknown_issuer)
That looks like what I see in Firefox when I go to a site that's using a non-verified SSL certificate. Is that from Firefox and not from the site? But if it is due to the site, I'm not surprised, but I don't have any control over that. If the SSL certificate bothers you, you can also look at the Cabal file and the other source on the Hackage page: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/emgm But of course the Setup.lhs is not there. The test argument to Setup seems nice. Is there some
already defined on the hook for tests?
Yes, that's the 'runTests' that we use. It's documented in the Cabal user's guide: http://www.haskell.org/cabal/release/latest/doc/users-guide/builders.html#se... Sean

You might consider looking at the EMGM cabal file in the source.
https://svn.cs.uu.nl:12443/viewvc/dgp-haskell/EMGM/
> (...)
>From the site:
Échec de la connexion sécurisée svn.cs.uu.nl:12443 http://svn.cs.uu.nl:12443 utilise un certificat de sécurité invalide. Le certificat n'est pas sûr car l'autorité délivrant le certificat est inconnue. (Code d'erreur : sec_error_unknown_issuer)
That looks like what I see in Firefox when I go to a site that's using a non-verified SSL certificate. (...)
Right. I didn't know I could just accept that and go further... Yours is actually a very good example on how to build a customized cabal package :) Thanks, Maurício
participants (2)
-
Mauricio
-
Sean Leather