
I have started an alternative implementation of 'doctest'. In contrast to the original one, doctest-extract extracts Haskell test-modules from doctest comments. This integrates better with Cabal and its package version resolution and the tests are compiled, not interpreted in GHCi. Disadvantage is that doctest-extract does not support all features of 'doctest', e.g. IO-tests. I uploaded a preview as package candidates to Hackage: $ cabal install $(for pkg in doctest-extract-0.0 doctest-lib-0.0 utility-ht-0.0.16 non-empty-0.3.3; do echo https://hackage.haskell.org/package/$pkg/candidate/$pkg.tar.gz; done) Extract test modules like so: $ doctest-extract -i src/ -o test/ --executable-main=Test/Main.hs --import-tested $$(cat test-module.list) There is still a problem: A failing QuickCheck test does not abort the whole test-suite. 'cabal test' will report success even if one QuickCheck property test fails. I wonder what is the proposed way to make a failing property fail the test-suite? I could use (QC.whenFail exitFailure). Is this the intended way?

On Sat, 1 Aug 2020, Henning Thielemann wrote:
There is still a problem: A failing QuickCheck test does not abort the whole test-suite. 'cabal test' will report success even if one QuickCheck property test fails. I wonder what is the proposed way to make a failing property fail the test-suite? I could use (QC.whenFail exitFailure). Is this the intended way?
(whenFail exitFailure) would not even help. QuickCheck catches it and keeps going. :-(

Hi Henning: I’m quite interested in this, especially as doctest on GHC 8.10 has issues: https://github.com/sol/doctest/issues/264 https://github.com/sol/doctest/issues/264 Furthermore, compiling doctests would be a huge performance boost and can speed up CI times significantly. I’m curious why your new package does not support IO-tests. Is that a “current” limitation, or is there a fundamental reason why IO-tests ca not be supported using your approach. Cheers, -Levent.
On Aug 1, 2020, at 3:15 AM, Henning Thielemann
wrote: I have started an alternative implementation of 'doctest'. In contrast to the original one, doctest-extract extracts Haskell test-modules from doctest comments. This integrates better with Cabal and its package version resolution and the tests are compiled, not interpreted in GHCi. Disadvantage is that doctest-extract does not support all features of 'doctest', e.g. IO-tests.
I uploaded a preview as package candidates to Hackage:
$ cabal install $(for pkg in doctest-extract-0.0 doctest-lib-0.0 utility-ht-0.0.16 non-empty-0.3.3; do echo https://hackage.haskell.org/package/$pkg/candidate/$pkg.tar.gz; done)
Extract test modules like so:
$ doctest-extract -i src/ -o test/ --executable-main=Test/Main.hs --import-tested $$(cat test-module.list)
There is still a problem: A failing QuickCheck test does not abort the whole test-suite. 'cabal test' will report success even if one QuickCheck property test fails. I wonder what is the proposed way to make a failing property fail the test-suite? I could use (QC.whenFail exitFailure). Is this the intended way? _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

On Mon, 3 Aug 2020, Levent Erkok wrote:
I’m quite interested in this, especially as doctest on GHC 8.10 has issues: https://github.com/sol/doctest/issues/264
interesting
Furthermore, compiling doctests would be a huge performance boost and can speed up CI times significantly.
right
I’m curious why your new package does not support IO-tests. Is that a “current” limitation, or is there a fundamental reason why IO-tests ca not be supported using your approach.
It is a deeper problem. doctest just runs GHCi and GHCi follows the built-in rule: If an expression is IO, then run IO and emit its stdio. If not, print the result of "show". That is, in order to make this distinction, doctest-extract would have to know the type of the test expression. However, doctest-extract extracts purely syntactically, and I prefer to keep it this way for simplicity. For now you may use quickCheck's IO testing. But can it check for stdio data? Alternatively I thought about letting the user mark IO examples in some way. Maybe I could ask the user to give a type signature to IO tests and switch on expressions that end with ":: IO".

Is there movement on doctest-extract? I'd really like doctest with my v2 cabal projects. On Mon, Aug 3, 2020 at 10:51 AM Henning Thielemann < lemming@henning-thielemann.de> wrote:
On Mon, 3 Aug 2020, Henning Thielemann wrote:
doctest just runs GHCi and GHCi follows the built-in rule: If an expression is IO, then run IO and emit its stdio.
I meant stdout, of course. Certainly also stderr. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

On Thu, 20 Aug 2020, Thomas DuBuisson wrote:
Is there movement on doctest-extract? I'd really like doctest with my v2 cabal projects.
I have solved the problem with letting the testsuite fail when a single test fails. To this end I implemented a Writer Monad that counts the failures and put this in the new package doctest-exitcode-stdio: $ cabal install $(for pkg in doctest-extract-0.1 doctest-lib-0.1 doctest-exitcode-stdio-0.0 utility-ht-0.0.16 non-empty-0.3.3; do echo https://hackage.haskell.org/package/$pkg/candidate/$pkg.tar.gz; done) I could also write an extractor for Cabal's 'detailed' test framework.

See https://stackoverflow.com/questions/8976488/quickcheck-exit-status-on-failur... The gist is that you have to get the results of the QuickCheck test(s) and use them outside the QuickCheck context. On Sat, Aug 1, 2020, 6:15 AM Henning Thielemann < lemming@henning-thielemann.de> wrote:
I have started an alternative implementation of 'doctest'. In contrast to the original one, doctest-extract extracts Haskell test-modules from doctest comments. This integrates better with Cabal and its package version resolution and the tests are compiled, not interpreted in GHCi. Disadvantage is that doctest-extract does not support all features of 'doctest', e.g. IO-tests.
I uploaded a preview as package candidates to Hackage:
$ cabal install $(for pkg in doctest-extract-0.0 doctest-lib-0.0 utility-ht-0.0.16 non-empty-0.3.3; do echo https://hackage.haskell.org/package/$pkg/candidate/$pkg.tar.gz; done)
Extract test modules like so:
$ doctest-extract -i src/ -o test/ --executable-main=Test/Main.hs --import-tested $$(cat test-module.list)
There is still a problem: A failing QuickCheck test does not abort the whole test-suite. 'cabal test' will report success even if one QuickCheck property test fails. I wonder what is the proposed way to make a failing property fail the test-suite? I could use (QC.whenFail exitFailure). Is this the intended way? _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

On Mon, 3 Aug 2020, David Feuer wrote:
See https://stackoverflow.com/questions/8976488/quickcheck-exit-status-on-failur...
The gist is that you have to get the results of the QuickCheck test(s) and use them outside the QuickCheck context.
Thank you for the hint! I got a similar hint off-list and already solved the problem this way.
participants (4)
-
David Feuer
-
Henning Thielemann
-
Levent Erkok
-
Thomas DuBuisson