-
Notifications
You must be signed in to change notification settings - Fork 52
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
Fix doctests #165
Fix doctests #165
Conversation
@@ -956,7 +956,7 @@ class Uniform a where | |||
-- | |||
-- There is a default implementation via 'Generic': | |||
-- | |||
-- >>> :set -XDeriveGeneric -XDeriveAnyClass | |||
-- >>> :seti -XDeriveGeneric -XDeriveAnyClass |
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.
@Bodigrim :set
sets options for source files and ghci
expressions, while :seti
only affects ghci
expressions.
- With
:set
those three tests were failing, I think due to a reincarnation of https://gitlab.haskell.org/ghc/ghc/-/issues/20670. - For doctests you usually want
:seti
anyway.
Why do the generated random numbers change? I would have thought with a fixed seed we should always get the same random numbers i.e. why this: https://github.com/haskell/random/pull/165/files#diff-fe93ae678c398cfea72ff60186cc2cee27bd752aad99d8fd1ece059c912f0104L645 |
@idontgetoutmuch I don't think the seed was fixed for those examples before this PR. |
@idontgetoutmuch That is because that example uses global StdGen, which as comment below example points out, is usually not a very good idea: Lines 647 to 650 in 623cf51
|
@@ -354,7 +354,7 @@ class Random a where | |||
-- independently: | |||
-- | |||
-- >>> fst $ randomR (('a', 5.0), ('z', 10.0)) $ mkStdGen 2021 | |||
-- ('t',6.240232662366563) | |||
-- ('t',6.240232662366564) |
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.
@idontgetoutmuch I am more curious to see floating point number generation be affected by the change of how doctests are being executed. I suspect this is coming from some ghc optimizations, so I don't think we'll be able to do anything about it, but it could be worth investigating where exactly it is coming from.
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.
Thank you for fixing doctest
for us @sol. I greatly appreciate it.
I could never figure out what was wrong with our current setup.
Could I ask you to change the CI in such a way that we run doctests for many ghc versions, instead of just one. This is quite important for making sure our examples also work the same for users of all supported ghc versions.
In fact we do fix seed for doctests. In module
Maybe cabal doctest executes modules in different order? |
I am sure that is the case. Which is also the reason why I always suggest avoid using the global generator whenever reproducability is important. |
Are there any release plans, btw? |
@juhp Yes, I am planning on making a release over Christmas break. In any case, I suspect stackage will be stuck on this for a while, since last time major version of I can try making a patch release of |
Yes that sounds good if you can, thank you! |
For now I try to disable the random testsuite in Stackage Nightly as a workaround hopefully |
Starting with `random-1.3.0` doctests are executed in a CI by invoking `doctest` executable directly, which turns out to be the correct way to use doctest. This was pointed out in #165 In order to avoid `random-1.2.x` major version depending on doctest, this patch removes doctest usage completely, in favor of a new setup going forward. However, in order to prevent tooling breakaage downstream that runs tests we do not remove the `doctest` executable section.
@juhp |
This addresses commercialhaskell/stackage#7493.