I am trying to write my own test framework and I can't even get started. Here is my directory structure:
$ tree
.
├── prj1
│ ├── package.yaml
│ ├── src
│ │ └── Module.hs
│ └── test-dir
│ └── TheTest.hs
└── stack.yaml
And each of the files is:
stack.yaml
resolver: lts-16.11
packages:
- prj1
package.yaml
name: prj1
version: 0.1
maintainer: fakedrake
category: Test
library:
source-dirs: src
exposed-modules: []
dependencies:
- base
tests:
prj1-tests:
main: TheTest.hs
source-dirs: test-dir
dependencies:
- base
TheTest.hs
module TheTest () where
main :: IO ()
main = putStrLn "Test passes!"
Module.hs
module Module () where
But when I run stack test I get
$ stack test
prj1> configure (lib + test)
Configuring prj1-0.1...
prj1> build (lib + test)
Preprocessing library for prj1-0.1..
Building library for prj1-0.1..
[1 of 2] Compiling Module
[2 of 2] Compiling Paths_prj1
Preprocessing test suite 'prj1-tests' for prj1-0.1..
Building test suite 'prj1-tests' for prj1-0.1..
[1 of 2] Compiling Paths_prj1
[2 of 2] Compiling TheTest
<no location info>: error:
output was redirected with -o, but no output will be generated
because there is no Main module.
-- While building package prj1-0.1 using:
/my/home/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.3 --builddir=.stack-work/dist/x86_64-osx/Cabal-3.0.1.0 build lib:prj1 test:prj1-tests --ghc-options ""
Process exited with code: ExitFailure 1
Progress 1/2
Main. So inTheTest.hsyou should changemodule TheTesttomodule Main, and probably also expose themainentrypoint.