bangalore-haskell-user-group / functorrent

A bit torrent client
GNU General Public License v3.0
18 stars 9 forks source link

Tests with tasty #9

Closed jaseemabid closed 9 years ago

jaseemabid commented 9 years ago

Managed to add some tests to my own lisper, will try to do some same for functorrent next weekend or so.

Hunit is a mess, and had a really bad time with it. It would always report a success and count to be 1. Thankfully Tasty feels really good. Got the whole thing hooked up with travis-ci so the builds are available publicly[2].

See the last few commits[1] for details. One of the main things to do was to split the project into a library and an executable.

Give it a try!

  1. https://github.com/jaseemabid/lisper/commits/master
  2. https://travis-ci.org/jaseemabid/lisper
jaseemabid commented 9 years ago

This should help http://jaspervdj.be/posts/2015-03-13-practical-testing-in-haskell.html

dfordivam commented 9 years ago

ok we can start with tasty. Can you commit a set of initial files required for this. Also I think we should pick some basic test-cases from the existing torrent test-suite. Here is a link to libtorrent's test-suite

dfordivam commented 9 years ago

I just realised that we are already creating test-cases from libtorrent

jaseemabid commented 9 years ago

Are we?

dfordivam commented 9 years ago

well the doctests are taken from https://github.com/libtorrent/libtorrent/blob/master/test/test_bencoding.cpp

jaseemabid commented 9 years ago

I'm not a fan of doctest. Its just cleaner to write good unit tests and run it regularly.

vu3rdd commented 9 years ago

I took the tests from the specification wiki.

jaseemabid commented 9 years ago

@vu3rdd @dfordivam Before we close this, do we want doctest at all? I think its just easier and cleaner to maintain simple plain old unit tests. Otherwise, I have to find a way to integrate doctests with tasty so that they are also run on travis.

jaseemabid commented 9 years ago

@vu3rdd Can you enable https://travis-ci.org/vu3rdd/functorrent? You will have to login with your github account. The tests should then run on every commit as well as pull request.

jaseemabid commented 9 years ago

Doctests seems to be broken anyway.

 $ .cabal-sandbox/bin/doctest src/FuncTorrent/Bencode.hs
### Failure in src/FuncTorrent/Bencode.hs:76: expression `parse bencList "Blist" (pack "l4:spam4:eggse")'
expected: Right ["spam","eggs"]
 but got: Right [Bstr "spam",Bstr "eggs"]
### Failure in src/FuncTorrent/Bencode.hs:90: expression `parse bencDict "Bdict" (pack "d3:cow3:moo4:spam4:eggse")'
expected: Right (fromList [("cow","moo"),("spam","eggs")])
 but got: Right (fromList [(Bstr "cow",Bstr "moo"),(Bstr "spam",Bstr "eggs")])
Examples: 27  Tried: 23  Errors: 0  Failures: 2