Coder Social home page Coder Social logo

Comments (5)

sol avatar sol commented on July 29, 2024 1

As I describe here sjakobi/bsb-http-chunked#38 (comment), if I invoke ghci the same way as doctest is invoked, I get the same error. So as far as I can tell, this is not a bug (by design, doctest tries to mimic ghci).

I'm closing this, but please don't be shy to open a new issue if you think there is something that we can do in doctest to improve the situation.

from doctest.

sol avatar sol commented on July 29, 2024

@sjakobi invoking doctest via cabal repl works for me:

$ cabal install doctest --overwrite-policy=always && cabal build && cabal repl --build-depends=QuickCheck --build-depends=template-haskell --with-ghc=doctest
Examples: 5  Tried: 5  Errors: 0  Failures: 0

Starting with doctest-0.20.0 that's how I recommend to use doctest with cabal-v2.

from doctest.

sjakobi avatar sjakobi commented on July 29, 2024

So as Ryan explains in https://gitlab.haskell.org/ghc/ghc/-/issues/20833#note_398289, the problem seems to be that the doctests invoked via cabal test end up using the default GHC2021 language variant, which leads to the type error in bsb-http-chunked.

To me that seems like a bug somewhere in cabal test or doctest. It's good that the workaround with cabal repl exists, but I hope that doctests will eventually be properly supported in cabal test again.

EDIT: For reference: haskell/cabal#4500 contains some discussion on better doctest support in cabal.

from doctest.

sol avatar sol commented on July 29, 2024

To me that seems like a bug somewhere in cabal test or doctest.

@sjakobi I'm not convinced that this is the case. doctest behaves the same as ghci, which is by design.

cabal test on the other hand merely runs your tests/Doctests.hs. I don't think it is in a position to influence how doctest is invoked.

What I assume is that you just need to pass -XHaskell2010 to doctest. Specifically, change tests/Doctests.hs to:

import Test.DocTest

main :: IO ()
main = doctest ["-isrc", "-XHaskell2010", "Data/ByteString/Builder/HTTP/Chunked.hs"]

(untested)

I still think that with doctest-0.20.0 the most reliabl way to use doctest is via cabal repl. Because this delegates the handling of all the details to cabal. So specifically this should work:

cabal install doctest --overwrite-policy=always && cabal build && cabal repl --build-depends=QuickCheck --build-depends=template-haskell --with-ghc=doctest

from doctest.

sjakobi avatar sjakobi commented on July 29, 2024

What I assume is that you just need to pass -XHaskell2010 to doctest.

Thank you, @sol! I had totally forgotten to check how these doctests are invoked.

I still think that with doctest-0.20.0 the most reliabl way to use doctest is via cabal repl.

This is good to know, but I'd really to prefer to be able to run the tests with just cabal test. The main problems I see with the cabal repl command is that I'd need to communicate this with contributors, and I'd also need to customize the CI configs which I usually just generate with haskell-ci.

I'd love to have good support for doctests built into cabal though. Maybe this cabal repl command or something like it can be built into cabal as a part of a new type: doctest test type?!

from doctest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.