byteverse / chronos

Haskell time library focusing on performance
Other
54 stars 22 forks source link

`doctest` suite failing for me on GHC 8.10.3 #62

Closed cideM closed 2 years ago

cideM commented 3 years ago

I'm trying to figure out why chronos doesn't build in Nixpkgs. So I cloned the repository and the ran the commands from appveyor.yml

$ cabal build all --enable-tests --write-ghc-environment-files=always
$ cabal test all --enable-test

but this gives me the following rather long list of errors

errors ``` Test suite doctest: RUNNING... ld: warning: /nix/store/hxcwxf1bhx8dhlyzjyzcgpw91b66cnrw-libiconv-osx-10.12.6/lib/libiconv.dylib, ignoring unexpected dylib file src/Chronos.hs:404: failure in expression `\(d :: Datetime) -> timeToDatetime (datetimeToTime d) == d' :359:18: error: Not in scope: data constructor ‘Datetime’ :359:36: error: Not in scope: type constructor or class ‘Datetime’ :360:3: error: Variable not in scope: polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ :360:19: error: Variable not in scope: mkName :: t1 -> t0 src/Chronos.hs:437: failure in expression `\(d :: Day) -> dateToDay (dayToDate d) == d' :486:18: error: Not in scope: data constructor ‘Day’ :486:31: error: Not in scope: type constructor or class ‘Day’ :487:3: error: Variable not in scope: polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ :487:19: error: Variable not in scope: mkName :: t1 -> t0 src/Chronos.hs:446: failure in expression `\(d :: Date) -> dayToDate (dateToDay d) == d' :613:18: error: Not in scope: data constructor ‘Date’ :613:32: error: Not in scope: type constructor or class ‘Date’ :614:3: error: Variable not in scope: polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ :614:19: error: Variable not in scope: mkName :: t1 -> t0 src/Chronos.hs:453: failure in expression `datetimeFromYmdhms 2014 2 26 17 58 52' expected: Datetime {datetimeDate = Date {dateYear = Year {getYear = 2014}, dateMonth = Month {getMonth = 1}, dateDay = DayOfMonth {getDayOfMonth = 26}}, datetimeTime = TimeOfDay {timeOfDayHour = 17, timeOfDayMinute = 58, timeOfDayNanoseconds = 52000000000}} but got: ^ :673:1: error: Variable not in scope: datetimeFromYmdhms :: t0 -> t1 -> t2 -> t3 -> t4 -> t5 -> t src/Chronos.hs:481: failure in expression `timeFromYmdhms 2014 2 26 17 58 52' expected: Time {getTime = 1393437532000000000} but got: ^ :732:1: error: Variable not in scope: timeFromYmdhms :: t0 -> t1 -> t2 -> t3 -> t4 -> t5 -> t src/Chronos.hs:760: failure in expression `isLeapYear (Year 1996)' expected: True but got: ^ :791:1: error: Variable not in scope: isLeapYear :: t0 -> t :791:13: error: Data constructor not in scope: Year :: t1 -> t0 src/Chronos.hs:808: failure in expression `encode_YmdHMS SubsecondPrecisionAuto w3c (timeToDatetime (timeFromYmdhms 2014 2 26 17 58 52))' expected: "2014-02-26T17:58:52" but got: ^ :850:1: error: Variable not in scope: encode_YmdHMS :: t0 -> t1 -> t2 -> t :850:15: error: Data constructor not in scope: SubsecondPrecisionAuto :850:38: error: Variable not in scope: w3c :850:43: error: Variable not in scope: timeToDatetime :: t3 -> t2 :850:59: error: Variable not in scope: timeFromYmdhms :: t4 -> t5 -> t6 -> t7 -> t8 -> t9 -> t3 src/Chronos.hs:811: failure in expression `\(s :: SubsecondPrecision) (dt :: Datetime) -> isJust (decode_YmdHMS w3c (encode_YmdHMS s w3c dt))' :919:18: error: Not in scope: data constructor ‘SubsecondPrecision’ :919:37: error: Not in scope: data constructor ‘Datetime’ :919:55: error: Not in scope: type constructor or class ‘SubsecondPrecision’ :919:82: error: Not in scope: type constructor or class ‘Datetime’ :920:3: error: Variable not in scope: polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ :920:19: error: Variable not in scope: mkName :: t1 -> t0 src/Chronos.hs:818: failure in expression `encode_YmdHMS SubsecondPrecisionAuto slash (timeToDatetime (timeFromYmdhms 2014 2 26 17 58 52))' expected: "2014/02/26 17:58:52" but got: ^ :979:1: error: Variable not in scope: encode_YmdHMS :: t0 -> t1 -> t2 -> t :979:15: error: Data constructor not in scope: SubsecondPrecisionAuto :979:38: error: Variable not in scope: slash :979:45: error: Variable not in scope: timeToDatetime :: t3 -> t2 :979:61: error: Variable not in scope: timeFromYmdhms :: t4 -> t5 -> t6 -> t7 -> t8 -> t9 -> t3 src/Chronos.hs:821: failure in expression `\(s :: SubsecondPrecision) (dt :: Datetime) -> isJust (decode_YmdHMS slash (encode_YmdHMS s slash dt))' :1048:18: error: Not in scope: data constructor ‘SubsecondPrecision’ :1048:37: error: Not in scope: data constructor ‘Datetime’ :1048:55: error: Not in scope: type constructor or class ‘SubsecondPrecision’ :1048:82: error: Not in scope: type constructor or class ‘Datetime’ :1049:3: error: Variable not in scope: polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ :1049:19: error: Variable not in scope: mkName :: t1 -> t0 src/Chronos.hs:828: failure in expression `encode_YmdHMS SubsecondPrecisionAuto hyphen (timeToDatetime (timeFromYmdhms 2014 2 26 17 58 52))' expected: "2014-02-26 17:58:52" but got: ^ :1108:1: error: Variable not in scope: encode_YmdHMS :: t0 -> t1 -> t2 -> t :1108:15: error: Data constructor not in scope: SubsecondPrecisionAuto :1108:38: error: Variable not in scope: hyphen :1108:46: error: Variable not in scope: timeToDatetime :: t3 -> t2 :1108:62: error: Variable not in scope: timeFromYmdhms :: t4 -> t5 -> t6 -> t7 -> t8 -> t9 -> t3 src/Chronos.hs:831: failure in expression `\(s :: SubsecondPrecision) (dt :: Datetime) -> isJust (decode_YmdHMS hyphen (encode_YmdHMS s hyphen dt))' :1177:18: error: Not in scope: data constructor ‘SubsecondPrecision’ :1177:37: error: Not in scope: data constructor ‘Datetime’ :1177:55: error: Not in scope: type constructor or class ‘SubsecondPrecision’ :1177:82: error: Not in scope: type constructor or class ‘Datetime’ :1178:3: error: Variable not in scope: polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ :1178:19: error: Variable not in scope: mkName :: t1 -> t0 src/Chronos.hs:838: failure in expression `encode_YmdHMS SubsecondPrecisionAuto compact (timeToDatetime (timeFromYmdhms 2014 2 26 17 58 52))' expected: "20140226T175852" but got: ^ :1237:1: error: Variable not in scope: encode_YmdHMS :: t0 -> t1 -> t2 -> t :1237:15: error: Data constructor not in scope: SubsecondPrecisionAuto :1237:38: error: Variable not in scope: compact :1237:47: error: Variable not in scope: timeToDatetime :: t3 -> t2 :1237:63: error: Variable not in scope: timeFromYmdhms :: t4 -> t5 -> t6 -> t7 -> t8 -> t9 -> t3 src/Chronos.hs:841: failure in expression `\(s :: SubsecondPrecision) (dt :: Datetime) -> isJust (decode_YmdHMS compact (encode_YmdHMS s compact dt))' :1306:18: error: Not in scope: data constructor ‘SubsecondPrecision’ :1306:37: error: Not in scope: data constructor ‘Datetime’ :1306:55: error: Not in scope: type constructor or class ‘SubsecondPrecision’ :1306:82: error: Not in scope: type constructor or class ‘Datetime’ :1307:3: error: Variable not in scope: polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ :1307:19: error: Variable not in scope: mkName :: t1 -> t0 src/Chronos.hs:2691: failure in expression `\(t :: Time) -> within t whole' :1433:18: error: Not in scope: data constructor ‘Time’ :1433:32: error: Not in scope: type constructor or class ‘Time’ :1434:3: error: Variable not in scope: polyQuickCheck :: t0 -> Language.Haskell.TH.Lib.Internal.ExpQ :1434:19: error: Variable not in scope: mkName :: t1 -> t0 Examples: 31 Tried: 30 Errors: 0 Failures: 15 Test suite doctest: FAIL Test suite logged to: /Users/yuuki/nixstuff/chronos/dist-newstyle/build/x86_64-osx/ghc-8.10.3/chronos-1.1.2/t/doctest/test/chronos-1.1.2-doctest.log ```

which is also what Nixpkgs has problems with.

[nix-shell:~/nixstuff/chronos]$ cabal --version
cabal-install version 3.2.0.0
compiled using version 3.2.1.0 of the Cabal library
[nix-shell:~/nixstuff/chronos]$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.3

The issue does not happen on my NixOS machine which is using ghc 8.8.4. If I switch GHC on MacOS

$ nix-shell -p haskell.compiler.ghc884 cabal-install
$ [nix-shell:~/nixstuff/chronos]$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.8.4

it also passes on that machine.

Let me know if you need more information

andrewthad commented 3 years ago

I'm able to reproduce this issue on Ubuntu:

cabal build chronos:chronos-test --write-ghc-environment-files=always --enable-tests
cabal build chronos:doctest
/home/amartin/Development/chronos/dist-newstyle/build/x86_64-linux/ghc-8.10.3/chronos-1.1.2/t/doctest/build/doctest/doctest

This fails with the same error you are getting on NixOS. I have no idea why this happens. Also, the doctests are running really slowly, even the ones that succeed. I have no idea why this is failing, but I am inclined to just give up on doctest. It just keeps breaking once or twice every year.

ezzieyguywuf commented 3 years ago

I am able to reproduce in gentoo.

andrewthad commented 2 years ago

In 7bbd0a849b1ab541b53b3e876b7738758f141dfa, I have introduced a change that fixes this. I believe that it should work on gentoo now. I'm not sure about nix since it requires having doctest on the path, but perhaps the readme could be updated to explain how to make this work with nix. But the original issue will now be moot since nixpkgs will not try to run the doctests.

andrewthad commented 2 years ago

Marking this issue as closed since I think this should not cause any trouble any more. Open a new issue if it is possible to reproduce with chonos-1.1.4 or later.