Testing unpure network code

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Testing unpure network code

Maciej Piechotka
Hello. I have a problem with testing. I've wrote a client library for
NNTP protocol. However I don't know how to test it.

I though about spawning a thread for server inside a test but Haskell
(ghc and hugs?) uses green blocking threads so forkIO is not an option.
I cannot also use POSIX fork as in documentation it is stated that I
cannot use IO in argument. I'd not like to create separate process as
IPC is not something nice (and there is separation between two parts of
test). Testing on real server have also some disadvantages (on real one
it is not predictable and setting one just for tests...)

What is the correct solution?

PS. Please CC me as I'm not subscribe to the list. I will eventually use
Gmane but well. I'm in the process of writing NNTP client as no other
suited me ;)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/beginners/attachments/20090611/eb10d595/attachment.bin
Reply | Threaded
Open this post in threaded view
|

Testing unpure network code

Isaac Dupree-3
Maciej Piechotka wrote:
> Hello. I have a problem with testing. I've wrote a client library for
> NNTP protocol. However I don't know how to test it.
>
> I though about spawning a thread for server inside a test but Haskell
> (ghc and hugs?) uses green blocking threads so forkIO is not an option.

GHC forkIO uses threads that can make blocking foreign calls in parallel
(*not* blocking the whole process), at least if you compile with
ghc -threaded

-Isaac
Reply | Threaded
Open this post in threaded view
|

Testing unpure network code

Maciej Piechotka
On Thu, 2009-06-11 at 09:59 -0400, Isaac Dupree wrote:

> Maciej Piechotka wrote:
> > Hello. I have a problem with testing. I've wrote a client library for
> > NNTP protocol. However I don't know how to test it.
> >
> > I though about spawning a thread for server inside a test but Haskell
> > (ghc and hugs?) uses green blocking threads so forkIO is not an option.
>
> GHC forkIO uses threads that can make blocking foreign calls in parallel
> (*not* blocking the whole process), at least if you compile with
> ghc -threaded
>
> -Isaac

Thank you. Is there any guide how to set up tests? I have sources in
src/ directory and tests in tests/.

Regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/beginners/attachments/20090612/b3f905df/attachment.bin
Reply | Threaded
Open this post in threaded view
|

Testing unpure network code

Maciej Piechotka
On Fri, 2009-06-12 at 13:03 +0200, Maciej Piechotka wrote:

> On Thu, 2009-06-11 at 09:59 -0400, Isaac Dupree wrote:
> > Maciej Piechotka wrote:
> > > Hello. I have a problem with testing. I've wrote a client library for
> > > NNTP protocol. However I don't know how to test it.
> > >
> > > I though about spawning a thread for server inside a test but Haskell
> > > (ghc and hugs?) uses green blocking threads so forkIO is not an option.
> >
> > GHC forkIO uses threads that can make blocking foreign calls in parallel
> > (*not* blocking the whole process), at least if you compile with
> > ghc -threaded
> >
> > -Isaac
>
> Thank you. Is there any guide how to set up tests? I have sources in
> src/ directory and tests in tests/.
>
> Regards

Ok. I found out. For those who will search - -i option sets the search
path so runhaskell -isrc test/... will do.

Regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/beginners/attachments/20090612/1353a156/attachment.bin