karun012 / doctest-discover

Easy way to run doctests via cabal
The Unlicense
37 stars 8 forks source link

error: module ‘main:Bar’ is defined in multiple files #16

Open kindaro opened 6 years ago

kindaro commented 6 years ago

What I do: I have a few doctests in the module Symbolic.hs of the project symbolic. It's nothing special. doctest runs manually from command line without any sign of misbehaviour, correctly performs the tests specified in the module. I try to set up doctest-discover to run tests with stack.

My expectations: When set up in package.yaml as recommended, doctest will be run by stack test successfully.

What happens: Everything builds alright. As the process enters the testing stage, an error occurs:

symbolic-0.1.0.0: test (suite: doctest)

Progress: 3/4
<no location info>: error:
    module ‘main:Bar’ is defined in multiple files: /home/kindaro/code/symbolic/.stack-work/downloaded/wTjnDRat1Snx/doctest-master/test/extract/imported-module/Bar.hs
                                                    /home/kindaro/code/symbolic/.stack-work/downloaded/wTjnDRat1Snx/doctest-master/test/extract/th/Bar.hs
                                                    /home/kindaro/code/symbolic/.stack-work/downloaded/wTjnDRat1Snx/doctest-master/test/integration/with-cbits/Bar.hs
                                                    /home/kindaro/code/symbolic/.stack-work/downloaded/wTjnDRat1Snx/doctest-master/test/integration/custom-package-conf/Bar.hs                                                  
Completed 4 action(s).
Test suite failure for package symbolic-0.1.0.0
    doctest:  exited with: ExitFailure 1

I don't know what to do. These files in .stack-work apparently belong to doctest, not doctest-discover, but, as I said, I can run doctest from command line without any issues. I am reporting this here because I have no better idea.

These are the relevant code extracts:

doctest-config.json

{
    "sourceFolders": ["."], 
    "ignore": ["src"]
}

doctest-driver.hs

{-# OPTIONS_GHC -F -pgmF doctest-discover -optF doctest-config.json #-}

package.yaml

name: symbolic
version: 0.1.0.0
license: ISC

ghc-options: -Wall

dependencies:
  - base >= 4.8 && < 5
  - transformers
  - mtl
  - text

library:
  source-dirs: .

tests:
    doctest:
        main: doctest-driver.hs
        dependencies:
            - base >4 && <5
            - doctest
            - doctest-discover
        source-dirs: .

I will appreciate any advice.

karun012 commented 6 years ago

Are you using a local copy of doctest-discover?

kindaro commented 6 years ago

@karun012 Yes, I cloned this repo and stack installed from there. This was the wrong thing to do. I just stack installed whatever version comes from Stackage and it works flawlessly.

karun012 commented 6 years ago

Awesome. I'll leave this issue open. I'd like to make sure it works even if you use a local copy.