How to use cabal-dev ghci and multiple targets/build-depends from cabal file?

160 views
Skip to first unread message

Kirill Zaborsky

unread,
Jul 11, 2013, 7:55:15 AM7/11/13
to haskel...@googlegroups.com
Currently I'm creating a small library and I wanted to create tests for it. So I have a library section in cabal file and also a test-suite section.

Everything goes well but when I tried to load file with tests into ghci (actually it was a REPL in emacs) I received errors stating that GHCi can not find e.g. Test.Framework module.

Is there any way to use multiple build-depends in GHCi?

KInd regards,
Kirill Zaborsky

Kirill Zaborsky

unread,
Jul 11, 2013, 8:19:40 AM7/11/13
to haskel...@googlegroups.com
The onlys solution I see at the moment is to get rid of cabal-dev and install dependencies globally (which works quite OK with gentoo-haskell)

Kind regards,
Kirill Zaborsky

четверг, 11 июля 2013 г., 15:55:15 UTC+4 пользователь Kirill Zaborsky написал:

Kirill Zaborsky

unread,
Jul 12, 2013, 1:04:09 AM7/12/13
to Rogan Creswick, haskel...@googlegroups.com
Hello Rogan,
Yes, I'm using cabal-dev ghci.
I've  created a test project https://github.com/qrilka/ghci-test and almost complete bash session could be seen at https://gist.github.com/qrilka/5981650
When I cal cabal-dev ghci I get "Could not find module `Test.HUnit'" and when using ghci (and passing -isrc to get project sources visible) I get tests module loaded properly.
Could it be some issue with hs-source-dirs maybe?

Kind regards,
Kirill Zaborsky


2013/7/12 Rogan Creswick <cres...@gmail.com>
On Thu, Jul 11, 2013 at 4:55 AM, Kirill Zaborsky <qri...@gmail.com> wrote:
Currently I'm creating a small library and I wanted to create tests for it. So I have a library section in cabal file and also a test-suite section.

Everything goes well but when I tried to load file with tests into ghci (actually it was a REPL in emacs) I received errors stating that GHCi can not find e.g. Test.Framework module.

Are you using the ghci command directly, or calling it via 'cabal-dev ghci' ? (the later should work)

--Rogan
 

Is there any way to use multiple build-depends in GHCi?

KInd regards,
Kirill Zaborsky

_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



Kirill Zaborsky

unread,
Jul 12, 2013, 3:59:13 AM7/12/13
to haskel...@googlegroups.com
It looks like cabal repl [1] could solve this kind of problems, but it is not clear when it will be merged in cabal HEAD.


KInd regards,
Kirill Zaborsky

четверг, 11 июля 2013 г., 15:55:15 UTC+4 пользователь Kirill Zaborsky написал:
Currently I'm creating a small library and I wanted to create tests for it. So I have a library section in cabal file and also a test-suite section.

Kirill Zaborsky

unread,
Jul 16, 2013, 2:42:05 AM7/16/13
to Rogan Creswick, haskel...@googlegroups.com
Hi Rogan,
Your answer seems to be reasonable. It looks like --enable-tests should be passed directly (as it is not my cabal file flag). But still I do not get success with it - https://gist.github.com/qrilka/6006305
If you say that it works for you would you mind to share exact shell log so maybe I'll figure out what am I doing wrong?
BTW I'm using the latest 0.9.2 version of cabal-dev with Cabal 1.16.0.3

Kind regards,
Kirill Zaborsky



2013/7/16 Rogan Creswick <cres...@gmail.com>
Hi Kirill,

I'm sorry for the delay in getting back to you.  The main problem is based on a misconception about cabal-dev that comes up frequently.

You do not need to 'configure' and 'build' with cabal-dev.  In fact, you shouldn't do so (unless you /really/ understand the internals, and it's very rare that you actually /need/ to do that).

Generally speaking, you only need one command:

$ cabal-dev install

That will build all dependencies, configure your project (with flags, if you use the --flags="..." param) and install your library / program into the cabal-dev sandbox.  This is important in your situation because cabal-dev configure and cabal-dev build do not install dependencies in a sandbox -- cabal-dev install does that step.

What I'm confused by is why the command 'cabal-dev configure --enable-tests' succeeded for you.  It looks like there may be a bug in cabal-dev that allows user-package db entries to interfere with configure, but I'm not really sure what's going on.

I just tried building and using cabal-dev ghci with your sample project, and it should work fine if you delete your cabal-dev sandbox, and then run:

$ cabal-dev install --flags="--enable-tests"
...
$ cabal-dev ghci

--Rogan



Reply all
Reply to author
Forward
0 new messages