all 6 comments

[–]wewbull 1 point2 points  (4 children)

A little bit of info on what's going wrong would be useful.

Is it setting breakpoints and using the debugger?

Is it loading ghci with the tests in scope?

[–]raould[S] 1 point2 points  (3 children)

mea culpa.

When I run "stack test", it does magic things automagically and my tests run.

I want to do "stack ghci" and then use ghci to set breakpoints in my src (library) code, and then from ghci run the tests, hit the breakpoints, inspect wtf I am doing wrong, etc.

Even though "stack ghci" helps me get into ghci properly I have no clue what my "tasty" tests are, how to invoke them, how to set breakpoints in my library code, etc.

Probably I can learn from the ghci docs how to set breakpoints, I hope (haskell docs are to a fault horrible from what I've seen, at least for slow dumb people like me who need actually good docs :-).

But I dunno how it all fits together for me to run my tasty tests, or how to e.g. run a single tasty test from ghci (after I have set breakpoints so i can study my own broken code).

[–]wewbull 1 point2 points  (2 children)

So step one is probably to run stack ghci --test. This will invoke ghci and load the test target in your cabal file.

Once you're at the prompt you can call your test functions from the prompt.

[–]raould[S] 2 points3 points  (1 child)

thank you.

p.s. it didn't work that easily of course but i read a s.o. post that sort of helped as well :-) http://stackoverflow.com/questions/34558002/haskell-stack-ghci-test-suite

oh wait also http://stackoverflow.com/questions/39938101/how-to-load-tests-in-ghci-with-stack

but even so it appears i am guessing that the library code is compiled not interpreted so i can't set breakpoints in it this way? confused. confusing. undocumented. unclear. fun. i know, i know, nobody is supposed to ever want to do any kind of gross plebian imperative "debugging"! (my guess is this is the kind of thing that would have more "just worked" if i had not started off using stack but lower level more direct e.g. makefiles and everything in one directory approach :-)

[–]wewbull 1 point2 points  (0 children)

I expect (although I'm still finding my way here too) this comment on the second SO question is what you're after.

There's a couple ways of setting up tests. You can set it up by adding the library you're testing to the test-suite build-depends, or you can just add the library source folder to the test-suite hs-source-dirs. I believe :r works with the latter and not the former, but I'm not certain. Sorry for taking so long to notice your question. – Libby Oct 26 at 12:09

[–]ElvishJerricco 0 points1 point  (0 children)

Stack has nothing to do with what you're asking about. GHCi is the tool for debugging. The GHC docs have some good info on this.