phadej / cabal-extras

A tool suite to aid Haskell development using `cabal-install`
81 stars 18 forks source link

cabal-docspec: bails out on TH names #113

Closed Lysxia closed 2 years ago

Lysxia commented 2 years ago

It seems doctests appearing after the first occurrence of a TH name ('foo) are getting skipped

-- | This is OK
--
-- >>> True
-- True

test = 'foo  -- TH name

-- | This is not OK, but this test is currently skipped.
-- 
-- >>> False
-- True

bar = undefined

I don't have a minimal repro right now but for example Data.Text contains many doctests that cabal-docspec only sees after commenting out the TH.Lift Text instance.

https://github.com/haskell/text/blob/577d1b61271662f840785a7bbf8672ec081e1791/src/Data/Text.hs#L400

phadej commented 2 years ago

I made a module like

{-# LANGUAGE TemplateHaskellQuotes #-}

module Test where

-- | This is OK
--
-- >>> True
-- True

test = 'maybe  -- TH name

-- | This is not OK, but this test is currently skipped.
-- 
-- >>> False
-- True

bar = undefined

and a package with it. Built the package and run cabal-docspec -v:

[   2.41179] docspec.phase2: Test
[   2.41199] ghci.input: :m Test
[   2.41458] ghci.input: :r
[   2.41656] ghci.input: :m Test
[   2.41852] ghci.input: :r
[   2.42052] ghci.input: True
[   2.42540] ghci.input: :m Test
[   2.42773] ghci.input: :r
[   2.42983] ghci.input: False
[   2.43309] error: False
[   2.43329] error: in comment at 12:1
expected: True
 but got: False

(line 12 is where second comment starts).

% cabal-docspec --version
0.0.0.20210228

Cannot reproduce. Will close in a week if there are no better reproducer.

Lysxia commented 2 years ago

Nevermind, I forgot to check I had an outdated cabal-docspec. Upgrading fixed the issue. Sorry for the noise.