Description
The CONTRIBUTING.md guide mentions how to run tests locally. Could we please update this with instructions on how to run doctests locally?
I'm looking at .github/workflows/quick-jobs.yml
and trying to follow along locally.
I've been invited to review #8086. Digging around I saw there were some related doctests I might run, HLS in vscode prompted me to refresh these and I saw the expected output had changed.
cabal/cabal-install/src/Distribution/Client/IndexUtils/IndexState.hs
Lines 55 to 72 in 8248c3d
I installed cabal-env
and cabal-docspec
. The latter worked well enough to show me that indeed some of the above expected outputs had changed.
> cabal-docspec --extra-package=QuickCheck &> docspec.txt
Here is a snippet with the change.
[ 9.72102] docspec.phase2: Distribution.Client.IndexUtils.IndexState
[ 9.75510] error: simpleParsec "2020-02-04T12:34:56Z, hackage.haskell.org HEAD" :: Maybe TotalIndexState
[ 9.75576] error: in comment at 55:1
expected: Just (TIS (IndexStateTime (TS 1580819696)) (fromList [(RepoName "hackage.haskell.org",IndexStateHead)]))
but got: Just (TIS (IndexStateTime (TS 1580819696)) (fromList [(RepoName {unRepoName = "hackage.haskell.org"},IndexStateHead)]))
Following the commands in quick-jobs.yml
I was surprised to see that this didn't pass.
> cabal-env --transitive QuickCheck
[ 0.00001] ghc.info: ghc
[ 0.00313] process.0.start: cwd=/var/folders/31/zb67fgcs66q4n3cs_wn134zr0000gn/T/ ghc --info
[ 0.11154] debug: GHC environment path: /Users/pdejoux/.ghc/x86_64-darwin-8.10.7/environments/default
[ 0.11291] cabal.plan: ... plan input summary TODO ...
[ 0.11412] process.1.start: cwd=/private/var/folders/31/zb67fgcs66q4n3cs_wn134zr0000gn/T/peura-XXXX-4b5a8722060ba021 cabal v2-build all --builddir=dist-newstyle
Resolving dependencies...
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):
- fake-package-0 (lib) (first run)
Configuring library for fake-package-0..
Building library for fake-package-0..
[ 6.07292] debug: writing environment file
[ 6.07752] peu.completed: OK
> cabal-env array bytestring containers deepseq directory filepath pretty process time binary unix text parsec mtl
[ 0.00000] ghc.info: ghc
[ 0.00029] process.0.start: cwd=/var/folders/31/zb67fgcs66q4n3cs_wn134zr0000gn/T/ ghc --info
[ 0.09733] debug: GHC environment path: /Users/pdejoux/.ghc/x86_64-darwin-8.10.7/environments/default
[ 0.09905] cabal.plan: ... plan input summary TODO ...
[ 0.10021] process.1.start: cwd=/private/var/folders/31/zb67fgcs66q4n3cs_wn134zr0000gn/T/peura-XXXX-b5794583c22d6fd1 cabal v2-build all --builddir=dist-newstyle
Resolving dependencies...
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):
- fake-package-0 (lib) (first run)
Configuring library for fake-package-0..
Building library for fake-package-0..
[ 5.48402] debug: writing environment file
[ 5.49061] peu.completed: OK
> cat $HOME/.ghc/*/environments/default
clear-package-db
global-package-db
package-db /Users/pdejoux/.cabal/store/ghc-8.10.4/package.db
package-id ghc-8.10.4
package-id bytestring-0.10.12.0
package-id unix-2.7.2.2
package-id base-4.14.1.0
package-id time-1.9.3
package-id hpc-0.6.1.0
package-id filepath-1.4.2.1
package-id process-1.6.9.0
package-id array-0.5.4.0
package-id integer-gmp-1.0.3.0
package-id containers-0.6.2.1
package-id ghc-boot-8.10.4
package-id binary-0.8.8.0
package-id ghc-prim-0.6.1
package-id ghci-8.10.4
package-id rts
package-id terminfo-0.4.1.4
package-id transformers-0.5.6.2
package-id deepseq-1.4.4.0
package-id ghc-boot-th-8.10.4
package-id pretty-1.1.3.6
package-id template-haskell-2.16.0.0
package-id directory-1.3.6.0
package-id text-1.2.4.1
package-id splt-0.2.3.4-aa9770d3
-- This is GHC environment file written by cabal-env
--
clear-package-db
global-package-db
package-db /Users/pdejoux/.cabal/store/ghc-8.10.7/package.db
package-id QckChck-2.14.2-e53cf042
package-id array-0.5.4.0
package-id base-4.14.3.0
package-id binary-0.8.8.0
package-id bytestring-0.10.12.0
package-id containers-0.6.5.1
package-id deepseq-1.4.4.0
package-id directory-1.3.6.0
package-id filepath-1.4.2.1
package-id ghc-boot-th-8.10.7
package-id ghc-prim-0.6.1
package-id integer-gmp-1.0.3.0
package-id mtl-2.2.2
package-id parsec-3.1.14.0
package-id pretty-1.1.3.6
package-id process-1.6.13.2
package-id rndm-1.2.1.1-5fe50b53
package-id rts
package-id spltmx-0.1.0.4-8aad226d
package-id template-haskell-2.16.0.0
package-id text-1.2.4.1
package-id time-1.9.3
package-id transformers-0.5.6.2
package-id unix-2.7.2.2
-- cabal-env packages:
-- cabal-env QuickCheck,
-- cabal-env array,
-- cabal-env binary,
-- cabal-env bytestring,
-- cabal-env containers,
-- cabal-env deepseq,
-- cabal-env directory,
-- cabal-env filepath,
-- cabal-env mtl,
-- cabal-env parsec,
-- cabal-env pretty,
-- cabal-env process,
-- cabal-env text,
-- cabal-env time,
-- cabal-env unix
-- cabal-env
-- cabal-env transitive: True
-- cabal-env plan:
-- cabal-env /Td6WFoAAATm1rRGAgAhARYAAAB0L+Wj4Bb+BXldAD2IiGZT0UYdkKRpnoLIXvjSQtxNmBKEartgr2VS
-- cabal-env VL61ktYGBrmqNToAJoPQd8QdbQfdqTKRZShvizXar6X6kLZ1rhlLndf4+9hZUcndgz47mq24oDdZRqt6
-- cabal-env +tajq7j1b3RzG7RRPc2zXnnodEWGDu6WEqSXSOMWoXKWf7nPlQsJ2dCNcUizd/xz4c7zjHeg4rIugLPb
-- cabal-env HirSrKmKZXOkyRq5kjRrC2FsXnTrtA13TuNVtLsP3LUZmwfVzN68fMipbrmJNld3h3Rv3KyFabWjQ9vT
-- cabal-env IaP8s/M+Wi/R9mHb5TZ5SakaPucYTFRv9N6BF49+aFJmsB15ZtAFGGM91RCHSFI3ORGU9YczQWeClceJ
-- cabal-env T/VZm7PpQdn2/0kuC0fehL5zqWoM3K56fe98w5W8jRlyaZhro5Xle0tNikSEVF2o+aQAiF/rIFIu0hiK
-- cabal-env skdOKOSIVh50bzInMMEd7+Kz7j74+8ymBMmlqLd/Xbzqy5Q3NimG0yPKwKGv1EbvYeGy62Dipp4dBQ11
-- cabal-env xw3TubfUy6nv1fcm99VIhyOPDolPJj9rkCZBS1RB5V53wsFlwjcQpzp5x4ehmrmamRCFcjjLUHMXrwXP
-- cabal-env tDAFq58DjKch8JpD4hInHijeoFDU4eQXgxPv+S5j6v0xUX0x8beYjheCEXSInqMVr48XCzUsslgozrXc
-- cabal-env 7n+7UVsOP3eVQWRCz2SS4p985jhOL8noNwPdgpggvMKwODGAwtiYRJ24s0OmSEJ2AxdtektCgR/chmLp
-- cabal-env kzZ00bbtX/k6LbBBAHXiU/ywBXvblY1YlnzGoEufdF89New3LTnddTUF44fI+auS94fiQmX6b0AWUo/A
-- cabal-env 2rLWqvMKk5y+qxaBQc2nJ7OvqohmO3I3T4migZQBWtzFR+ENmzEH1HU+TUKpw/H8bCUnAWRInkV1RH+g
-- cabal-env W3lNObE0AfcAlfK9yXX/lJAP4jy6nWYf0jDO1ggFaFfbdMT1gXHwdKloQra2Lsm5gkb9ogfO0eCQnnPm
-- cabal-env NHnl/j2QQAiTcBbAC+H27cvaKt/Wb0OuBA5VVh4tjMIEx7/D/CL6zs6XoC2ErJWw8Y6XP9VitvtHLFEZ
-- cabal-env rtxXiiC6W6INc6SI84dPRLT8Iu1TMzXiA7n6CNr6m6g6z1pZPxhyJwRlMLGw/lYJdQ/pZwX2nvic8SAy
-- cabal-env KZC3Y0InEo360WYXLmW4mOTUxUiEsoPF/G5AKlrfmxgkbZLyH+AaKR6W5rjVfP4Gp3OVkKeMKCkWfwGm
-- cabal-env e1nPZmkLviXAeySysYE5PiDFDI5BJiQ8XLbu3PKoav3BgWmr1Bm3zjntmpRKzJfO6yLWOO+wr3JAi2yy
-- cabal-env Xvdfx3EI0DRnXDvj6rXa9edA4FGqd50TuCczn271wv49Q9enchnv9+eC1v5/zlgrhK6r+wrD2TEujr6e
-- cabal-env +ppFlGs6+o0d9SV9rawVed+JW5Dc/a/2B9/oP2exjuvA70j8BS5aAphUS6kNiAfzI9PS+eknNMzfefRU
-- cabal-env aAKM0rzdc3UB1c9hOTOCatrhRQ+DaA6eaQcmwHEMXy9SYO0ljJSCkYZHWYUvMoyPwT14z3/CylQ9wQOq
-- cabal-env Y0rd5iC2yhY/KpDhjgQ7NY4MSmMF5ZHe0IPl5yLyjlTt5hKT6Wiseu/OBkogdwC1rZEFb+0hz0EE3Chc
-- cabal-env DrQD/XtX7M0nh71u9lzojbM9r5tb8R2jXm2s0xqtLnq8X+gaCaPqUrpAVMYPhz0mkPNE9QtQOxbWaBQ+
-- cabal-env t/QyPY1NC0gsVROnMd41sYO4k5xmL35k6kMTz3PC42Q82RzRKLZtcGaGraO02CJKQHFI2/e/d8Vu/2m4
-- cabal-env Age2UEItiPs3DzgbPZyQ+cNtVN9zUWFeqtsRYKxWKmSH4NmrfQUWFlj7oNe3ftDhn/BeaAAAAADM65SI
-- cabal-env 3FisvgABlQv/LQAAfrG+F7HEZ/sCAAAAAARZWg==
> make doctest
doctest --fast Cabal-syntax/src Cabal/src
Cabal-syntax/src/Distribution/Utils/Path.hs:41:10: error:
• Could not deduce (Typeable k)
arising from the superclasses of an instance declaration
from the context: (Typeable from, Typeable to)
bound by the instance declaration
at Cabal-syntax/src/Distribution/Utils/Path.hs:41:10-74
• In the instance declaration for
‘Structured (SymbolicPath from to)’
Cabal/src/Distribution/PackageDescription/Check.hs:2191: failure in expression `let test fp = putStrLn $ show (isGoodRelativeDirectoryPath fp) ++ "; " ++ show (isGoodRelativeFilePath fp)'
expected:
but got:
^
<interactive>:31:32: error:
Variable not in scope: isGoodRelativeDirectoryPath :: t -> a1
<interactive>:31:81: error:
Variable not in scope: isGoodRelativeFilePath :: t -> a0
Cabal/src/Distribution/Simple/BuildTarget.hs:185: failure in expression `readUserBuildTarget "comp"'
expected: Right (UserBuildTargetSingle "comp")
but got:
^
<interactive>:35:1: error:
Variable not in scope: readUserBuildTarget :: String -> t
Cabal-syntax/src/Distribution/InstalledPackageInfo.hs:130: failure in expression `let ipi = emptyInstalledPackageInfo { maintainer = "Tester" }'
expected:
but got:
^
<interactive>:45:39: error: Not in scope: ‘maintainer’
Cabal-syntax/src/Distribution/FieldGrammar/Newtypes.hs:120: failure in expression `:t alaList VCat'
expected: alaList VCat :: [a] -> List VCat (Identity a) a
but got:
^
<interactive>:1:1: error: Variable not in scope: alaList :: t0 -> t
<interactive>:1:9: error: Data constructor not in scope: VCat
Cabal-syntax/src/Distribution/FieldGrammar/Newtypes.hs:150: failure in expression `:t alaSet VCat'
expected: alaSet VCat :: Set a -> Set' VCat (Identity a) a
but got:
^
<interactive>:1:1: error: Variable not in scope: alaSet :: t0 -> t
<interactive>:1:8: error: Data constructor not in scope: VCat
Cabal-syntax/src/Distribution/FieldGrammar/Newtypes.hs:186: failure in expression `:t alaNonEmpty VCat'
expected: alaNonEmpty VCat :: NonEmpty a -> NonEmpty' VCat (Identity a) a
but got:
^
<interactive>:1:1: error:
Variable not in scope: alaNonEmpty :: t0 -> t
<interactive>:1:13: error: Data constructor not in scope: VCat
Cabal-syntax/src/Distribution/License.hs:180: failure in expression `licenseFromSPDX . licenseToSPDX $ BSD3'
expected: BSD3
but got:
^
<interactive>:61:1: error:
Variable not in scope: licenseFromSPDX :: b0 -> c
<interactive>:61:19: error:
Variable not in scope: licenseToSPDX :: a0 -> b0
<interactive>:61:35: error: Data constructor not in scope: BSD3
Cabal-syntax/src/Distribution/Types/Dependency.hs:80: failure in expression `prettyShow $ Dependency "pkg" anyVersion mainLibSet'
expected: "pkg"
but got:
^
<interactive>:65:1: error:
Variable not in scope: prettyShow :: a0 -> b
<interactive>:65:14: error:
Data constructor not in scope: Dependency :: t0 -> t1 -> t2 -> a0
<interactive>:65:31: error: Variable not in scope: anyVersion
<interactive>:65:42: error: Variable not in scope: mainLibSet
Cabal-syntax/src/Distribution/Types/Dependency.hs:111: failure in expression `simpleParsec "mylib:sub" :: Maybe Dependency'
expected: Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LSubLibName (UnqualComponentName "sub") :| [])))
but got:
^
<interactive>:69:35: error:
Not in scope: type constructor or class ‘Dependency’
Cabal-syntax/src/Distribution/Types/ExeDependency.hs:44: failure in expression `simpleParsec "happy:happy" :: Maybe ExeDependency'
expected: Just (ExeDependency (PackageName "happy") (UnqualComponentName "happy") (OrLaterVersion (mkVersion [0])))
but got:
^
<interactive>:73:37: error:
Not in scope: type constructor or class ‘ExeDependency’
Cabal-syntax/src/Distribution/Types/MungedPackageId.hs:83: failure in expression `import Distribution.Types.Version'
expected:
but got:
^
<interactive>:1:1: error:
attempting to use module ‘main:Distribution.Types.Version’ (Cabal-syntax/src/Distribution/Types/Version.hs) which is not loaded
Cabal-syntax/src/Distribution/Types/PackageVersionConstraint.hs:45: failure in expression `simpleParsec "foo" :: Maybe PackageVersionConstraint'
expected: Just (PackageVersionConstraint (PackageName "foo") (OrLaterVersion (mkVersion [0])))
but got:
^
<interactive>:83:29: error:
Not in scope: type constructor or class ‘PackageVersionConstraint’
Cabal-syntax/src/Distribution/Backpack.hs:116: failure in expression `eitherParsec "foobar" :: Either String OpenUnitId'
expected: Right (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "foobar"}))
but got:
^
<interactive>:87:40: error:
Not in scope: type constructor or class ‘OpenUnitId’
Cabal-syntax/src/Distribution/Backpack.hs:182: failure in expression `eitherParsec "Includes2-0.1.0.0-inplace-mysql:Database.MySQL" :: Either String OpenModule'
expected: Right (OpenModule (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "Includes2-0.1.0.0-inplace-mysql"})) (ModuleName "Database.MySQL"))
but got:
^
<interactive>:91:80: error:
Not in scope: type constructor or class ‘OpenModule’
Cabal-syntax/src/Distribution/Types/PackageId.hs:41: failure in expression `simpleParsec "foo-bar-0" :: Maybe PackageIdentifier'
expected: Just (PackageIdentifier {pkgName = PackageName "foo-bar", pkgVersion = mkVersion [0]})
but got:
^
<interactive>:95:35: error:
Not in scope: type constructor or class ‘PackageIdentifier’
Cabal/src/Distribution/Verbosity.hs:359: failure in expression `import Test.QuickCheck (Arbitrary (..), arbitraryBoundedEnum)'
expected:
but got:
^
<no location info>: error:
Could not find module ‘Test.QuickCheck’
It is not a module in the current program, or in any known package.
Cabal-syntax/src/Distribution/Types/Mixin.hs:46: failure in expression `simpleParsec "mylib" :: Maybe Mixin'
expected: Just (Mixin {mixinPackageName = PackageName "mylib", mixinLibraryName = LMainLibName, mixinIncludeRenaming = IncludeRenaming {includeProvidesRn = DefaultRenaming, includeRequiresRn = DefaultRenaming}})
but got:
^
<interactive>:103:31: error:
Not in scope: type constructor or class ‘Mixin’
Cabal-syntax/src/Distribution/SPDX/License.hs:58: failure in expression `eitherParsec "BSD-3-Clause AND MIT" :: Either String License'
expected: Right (License (EAnd (ELicense (ELicenseId BSD_3_Clause) Nothing) (ELicense (ELicenseId MIT) Nothing)))
but got:
^
<interactive>:107:54: error:
Not in scope: type constructor or class ‘License’
Cabal-syntax/src/Distribution/SPDX/LicenseId.hs:514: failure in expression `eitherParsec "BSD-3-Clause" :: Either String LicenseId'
expected: Right BSD_3_Clause
but got:
^
<interactive>:111:46: error:
Not in scope: type constructor or class ‘LicenseId’
Cabal-syntax/src/Distribution/SPDX/LicenseId.hs:535: failure in expression `licenseIdMigrationMessage "BSD3"'
expected: "Do you mean BSD-3-Clause?"
but got:
^
<interactive>:115:1: error:
Variable not in scope: licenseIdMigrationMessage :: t0 -> t
Cabal-syntax/src/Distribution/Types/Flag.hs:249: failure in expression `simpleParsec "" :: Maybe FlagAssignment'
expected: Just (fromList [])
but got:
^
<interactive>:119:26: error:
Not in scope: type constructor or class ‘FlagAssignment’
Cabal-syntax/src/Distribution/Types/MungedPackageName.hs:69: failure in expression `prettyShow $ MungedPackageName "servant" LMainLibName'
expected: "servant"
but got:
^
<interactive>:129:1: error:
Variable not in scope: prettyShow :: a0 -> b
<interactive>:129:14: error:
Data constructor not in scope: MungedPackageName :: t0 -> t1 -> a0
<interactive>:129:42: error:
Data constructor not in scope: LMainLibName
Cabal-syntax/src/Distribution/Types/MungedPackageName.hs:83: failure in expression `simpleParsec "servant" :: Maybe MungedPackageName'
expected: Just (MungedPackageName (PackageName "servant") LMainLibName)
but got:
^
<interactive>:135:33: error:
Not in scope: type constructor or class ‘MungedPackageName’
Cabal-syntax/src/Distribution/Types/MungedPackageName.hs:101: failure in expression `decodeCompatPackageName "z-servant-z-lackey"'
expected: MungedPackageName (PackageName "servant") (LSubLibName (UnqualComponentName "lackey"))
but got:
^
<interactive>:141:1: error:
Variable not in scope: decodeCompatPackageName :: t0 -> t
Cabal-syntax/src/Distribution/Types/MungedPackageName.hs:109: failure in expression `encodeCompatPackageName $ MungedPackageName "servant" (LSubLibName "lackey")'
expected: PackageName "z-servant-z-lackey"
but got:
^
<interactive>:147:1: error:
Variable not in scope: encodeCompatPackageName :: a0 -> b
<interactive>:147:27: error:
Data constructor not in scope: MungedPackageName :: t1 -> t2 -> a0
<interactive>:147:56: error:
Data constructor not in scope: LSubLibName :: t0 -> t2
Cabal-syntax/src/Distribution/Types/PkgconfigVersion.hs:45: failure in expression `simpleParsec "1.0.2n" :: Maybe PkgconfigVersion'
expected: Just (PkgconfigVersion "1.0.2n")
but got:
^
<interactive>:151:32: error:
Not in scope: type constructor or class ‘PkgconfigVersion’
Cabal-syntax/src/Distribution/Types/VersionRange/Internal.hs:234: failure in expression `fmap pretty (simpleParsec' CabalSpecV1_6 "== 3.2.*" :: Maybe VersionRange)'
expected: Just >=3.2 && <3.3
but got:
^
<interactive>:155:62: error:
Not in scope: type constructor or class ‘VersionRange’
Cabal-syntax/src/Distribution/Types/VersionRange/Internal.hs:286: failure in expression `simpleParsec "^>= 3.4" :: Maybe VersionRange'
expected: Just (MajorBoundVersion (mkVersion [3,4]))
but got:
^
<interactive>:159:33: error:
Not in scope: type constructor or class ‘VersionRange’
Examples: 156 Tried: 66 Errors: 0 Failures: 28
make: *** [doctest] Error 1
From looking at the MAKEFILE
I see there's also another target to run the doctests in cabal-install/src
that I'm interested in.
> make doctest-cli
doctest -D__DOCTEST__ --fast cabal-install/src cabal-install-solver/src cabal-install-solver/src-assertion
cabal-install/src/Distribution/Client/HashValue.hs:75:5: error:
error: function-like macro 'MIN_VERSION_base16_bytestring' is not defined
|
75 | #if MIN_VERSION_base16_bytestring(1,0,0)
| ^
#if MIN_VERSION_base16_bytestring(1,0,0)
^
1 error generated.
cabal-install/src/Distribution/Client/HttpUtils.hs:191:5: error:
error: function-like macro 'MIN_VERSION_base16_bytestring' is not defined
|
191 | #if MIN_VERSION_base16_bytestring(1,0,0)
| ^
#if MIN_VERSION_base16_bytestring(1,0,0)
^
1 error generated.
cabal-install/src/Distribution/Client/HashValue.hs:1:1: error:
`gcc' failed in phase `C pre-processor'. (Exit code: 1)
|
1 | {-# LANGUAGE CPP #-}
| ^
cabal-install/src/Distribution/Client/HttpUtils.hs:1:1: error:
`gcc' failed in phase `C pre-processor'. (Exit code: 1)
|
1 | {-# LANGUAGE BangPatterns #-}
| ^
make: *** [doctest-cli] Error 1