-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upadte README #321
Upadte README #321
Conversation
[Hackage](http://hackage.haskell.org/cgi-bin/hackage-scripts/package/doctest). | ||
Install it with: | ||
|
||
cabal update && cabal install doctest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cabal install
is not really compatible with a multi-GHC environment. I will just install doctest
that works with the current GHC. I would expect that rather one defines doctest
as a dependency in the .cabal
file and then it will be installed locally only, for the GHC version that is used to cabal test
the project.
With a `.cabal` file in place, it is possible to run `doctest` via `cabal repl`: | ||
|
||
``` | ||
cabal install doctest --overwrite-policy=always && cabal build && cabal repl --build-depends=QuickCheck --with-ghc=doctest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than installing doctest
, could it not some be located in the build-tree of the SUT?
Update: SUT = "system under test". Yeah, silly abbreviation, sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SUT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https:/sol/doctest-example is an alternative approach. That is add a doctest
flag to .cabal
/ package.yaml
:
flags:
doctest:
manual: True
default: False
when:
condition: flag(doctest)
build-tools: doctest
dependencies:
- QuickCheck
- template-haskell
and then invoke doctest
like so:
cabal build -fdoctest && cabal exec -fdoctest -- cabal repl -fdoctest --with-ghc=doctest
While this is more robust, it is not easier to document + there will be a bunch of people that will reject the "idea of modifying .cabal
just for tests", even though, guarded behind a flag, it has no tangible "cost" that I'm aware of.
An other option of course would be to install doctest
to the current working directory, somewhat cleaner maybe, but you still need to do it before each invocation, assuming that you sometimes switch GHC versions.
I'm not aware of anything that would e.g. tell cabal exec
to bring some executable into scope via command-line options. Arguably that is what we would want.
Just to be clear, you don't have to re-install doctest
before each invocation. If doctest
was built with a different version GHC than what you use for e.g. cabal build
then things will still work:
doctest
will run using the version of GHC it was built againstcabal repl
may need to rebuild dependencies for that version of GHC, which is fine, as long as it's notghc-paths
. At the pointghc-paths
gets built viacabal repl --with-ghc=doctest
, you potentially get into trouble.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andreasabel subject under test, I guess. Not that I'm aware of. At least not without modifying . If there is a way, I would be eager to learn about it.cabal.project[.local]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree I would not want to add such a flag to my projects.
I only know of the build-tool-depends: doctest:doctest
trick to pass in executable doctest
to a testsuite.
It might be worthwhile to refer to https:/Hexirp/doctest-driver-gen as well as a way to integrate doctest
.
Taking a step back, I would want my doctest-suites to run by a simple invocation of cabal test
or stack test
, nothing more than that. This way, they integrate smoothly with both stackage and haskell-ci
. Anything more complicated needs manually fiddling all the time, which I find tiresome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andreasabel the advantage of using cabal repl
is that it works reliably (modulo cabal repl
bugs of course, of which there hasn't been a shortage in the past neither). I don't think there is a way to make a cabal test suite work with Paths_*
(at least I'm not aware of anything).
I'm going to merge this, not because I think it's beautiful or perfect, but because it's the best thing I can come up with considering the current "state of cabal". Let's see how long it will work. I'm not saying there is an agenda, but @phadej being involved with At some point I may just follow @snoyberg's and @chrisdone's lead and call it a day. |
All that said, if somebody comes up with a better way to do it, I'm still very eager to learn about it. Specifically: Is there a way to bring an executable into scope (e.g. with One more thing. |
For the public record, I deleted a comment by @phadej, because I'm not going into a discussion on whether it's "necessary" to break other peoples code at will or not. For the interested reader, here is a discussion that I think is evident of how willing the cabal team was to prevent breakage of And for what it's worth, I don't think the discussion on that issue was evidence based: And for historic context and the LOLs of it, you may want to grab some popcorn 🍿 and beer 🍻 and read through the discussion of one of the very first PRs to PS: @phadej just to be very clear, I did not accuse you of anything. If you want to help I'm happy to have a discussion at |
I followed this lead and read through this discussion. This PR was almost bikeshedded to death. However, I have to say that I like |
No description provided.