
I just uploaded a new version of DocTest[1] to Hackage. WHAT IS DocTest? ================ DocTest is a port of Python's doctest[2] to Haskell. It can be used to verify, that examples in Haddock comments[3] do still work. This also provides you with a simple mechanism to write unit test, without the burden of maintaining a dedicated test suite. A basic example of usage is at [4]. WHAT'S NEW IN THIS VERSION? =========================== Support for blank lines in the result of an expression (analogous to the <BLANKLINE>-feature of Python's doctest). Here is an example of usage: -- | -- Some example: -- -- >>> putStrLn "foo\n\nbar" -- foo -- <BLANKLINE> -- bar Currently this is implemented in DocTest, but we will move it to Haddock with the next release. Cheers, Simon [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/DocTest [2] http://docs.python.org/library/doctest.html [3] http://www.haskell.org/haddock/doc/html/ch03s08.html#id566093 [4] http://haskell.org/haskellwiki/DocTest _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hi Simon,
Looking into DocTest has been something on my TODO list for a few months
now. After this email, I finally started looking into it. I was very
impressed to see that, with the optghc option, I'm even able to test
QuasiQuotes. Very impressive!
I would like to integrate DocTest into my normal test suite procedures. Do
you have a recommended approach for this? I think I have projects using all
of test-framework[1], HTF[2] and hspect[3], so I'm not picky here.
Michael
[1] http://hackage.haskell.org/package/test-framework
[2] http://hackage.haskell.org/package/HTF
[3] http://hackage.haskell.org/package/hspec
On Wed, Apr 6, 2011 at 7:46 PM, Simon Hengel
I just uploaded a new version of DocTest[1] to Hackage.
WHAT IS DocTest? ================
DocTest is a port of Python's doctest[2] to Haskell. It can be used to verify, that examples in Haddock comments[3] do still work. This also provides you with a simple mechanism to write unit test, without the burden of maintaining a dedicated test suite.
A basic example of usage is at [4].
WHAT'S NEW IN THIS VERSION? ===========================
Support for blank lines in the result of an expression (analogous to the <BLANKLINE>-feature of Python's doctest). Here is an example of usage:
-- | -- Some example: -- -- >>> putStrLn "foo\n\nbar" -- foo -- <BLANKLINE> -- bar
Currently this is implemented in DocTest, but we will move it to Haddock with the next release.
Cheers, Simon
[1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/DocTest [2] http://docs.python.org/library/doctest.html [3] http://www.haskell.org/haddock/doc/html/ch03s08.html#id566093 [4] http://haskell.org/haskellwiki/DocTest _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hello Michael,
I would like to integrate DocTest into my normal test suite procedures. Do you have a recommended approach for this? I think I have projects using all of test-framework[1], HTF[2] and hspect[3], so I'm not picky here.
Currently you are pretty much on your own here. A shell script that runs both, doctest and unit test, is what I currently use. In principle it should be possible to provide an API function that maps a list of flags and source files to tests, like: getDocTests :: [Flag] -> [FilePath] -> IO [Test] But with this you still have to figure out the flags and source files. A different approach would be to provide Cabal with a `doctest' target (similar to the `haddock' target), that runs the DocTests. Cabal already knows the necessary information to do so. Sadly, I have no time to work on any of these for at least a month. Nevertheless, I'd be interested what you think about it. Cheers, Simon

On Wed, Apr 6, 2011 at 11:53 PM, Simon Hengel
Hello Michael,
I would like to integrate DocTest into my normal test suite procedures. Do you have a recommended approach for this? I think I have projects using all of test-framework[1], HTF[2] and hspect[3], so I'm not picky here.
Currently you are pretty much on your own here. A shell script that runs both, doctest and unit test, is what I currently use.
In principle it should be possible to provide an API function that maps a list of flags and source files to tests, like:
getDocTests :: [Flag] -> [FilePath] -> IO [Test]
But with this you still have to figure out the flags and source files.
A different approach would be to provide Cabal with a `doctest' target (similar to the `haddock' target), that runs the DocTests. Cabal already knows the necessary information to do so.
Sadly, I have no time to work on any of these for at least a month. Nevertheless, I'd be interested what you think about it.
Cheers, Simon
I like the idea of a getDocTests function. In theory, it could take a cabal file as an argument, and use the Cabal library to get a list of all modules to be checked. It would also be convenient if it automatically passed in GHC options correlating to each LANGUAGE pragma found on a module. Michael

I like the idea of a getDocTests function. In theory, it could take a cabal file as an argument, and use the Cabal library to get a list of all modules to be checked. It would also be convenient if it automatically passed in GHC options correlating to each LANGUAGE pragma found on a module.
If you open up a ticket, I'll give it a try when I have a less tight schedule. Cheers, Simon

On Thu, Apr 7, 2011 at 11:43 AM, Simon Hengel
I like the idea of a getDocTests function. In theory, it could take a cabal file as an argument, and use the Cabal library to get a list of all modules to be checked. It would also be convenient if it automatically passed in GHC options correlating to each LANGUAGE pragma found on a module.
If you open up a ticket, I'll give it a try when I have a less tight schedule.
Cheers, Simon
Done: https://github.com/sol/doctest-haskell/issues/1 Thanks, a let me know if I can help with this. Michael
participants (2)
-
Michael Snoyman
-
Simon Hengel