mirror of
https://github.com/marcosh/crem.git
synced 2024-10-05 16:30:15 +03:00
run doctests as part of cabal test
This commit is contained in:
parent
58d3f1ba69
commit
b9a99914cc
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
||||
dist
|
||||
dist-*
|
||||
*.cabal
|
||||
.ghc.*
|
||||
|
||||
# nix
|
||||
result
|
||||
|
10
README.md
10
README.md
@ -116,3 +116,13 @@ Nix (or more precisely, Cabal2nix) uses a `.cabal` file if it is present, otherw
|
||||
- `crm.cabal`
|
||||
|
||||
This file is automatically generated from the `package.yaml` file and should not be committed to Git history.
|
||||
|
||||
### tool-specific files
|
||||
|
||||
- `fourmolu.yaml`
|
||||
|
||||
Configuration file for the [`fourmolu`](https://github.com/fourmolu/fourmolu) formatting tool.
|
||||
|
||||
- `.hspec`
|
||||
|
||||
Using a dedicated file to specify options for [`hspec`](https://hspec.github.io) allows passing options only to it. Using `cabal test --test-options` would pass options to all test stanzas instead.
|
||||
|
8
doctest/Main.hs
Normal file
8
doctest/Main.hs
Normal file
@ -0,0 +1,8 @@
|
||||
module Main where
|
||||
|
||||
import "base" System.Environment (getArgs)
|
||||
import "doctest-parallel" Test.DocTest (mainFromCabal)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
mainFromCabal "crm" =<< getArgs
|
@ -76,8 +76,10 @@
|
||||
"cabal build";
|
||||
|
||||
# Trigger a test execution every time a file changes
|
||||
# the --write-ghc-environment-files=always is required by doctest-parallel
|
||||
# see https://github.com/martijnbastiaan/doctest-parallel/blob/main/example/README.md#cabalproject
|
||||
test-watch = watch "test-watch"
|
||||
"cabal test --test-show-details=streaming --test-option=--color";
|
||||
"cabal test --test-show-details=streaming --write-ghc-environment-files=always";
|
||||
in
|
||||
rec {
|
||||
packages = {
|
||||
|
@ -1,4 +1,5 @@
|
||||
[
|
||||
"doctest"
|
||||
"src"
|
||||
"spec"
|
||||
"package.yaml"
|
||||
|
19
package.yaml
19
package.yaml
@ -92,13 +92,13 @@ ghc-options:
|
||||
|
||||
dependencies:
|
||||
- base
|
||||
- singletons-base
|
||||
- text
|
||||
|
||||
library:
|
||||
source-dirs: src
|
||||
dependencies:
|
||||
- profunctors
|
||||
- singletons-base
|
||||
- text
|
||||
# Disable adding Paths_crm to other-modules, because it does not conform to our style guide.
|
||||
# https://github.com/sol/hpack#handling-of-paths_-modules
|
||||
when:
|
||||
@ -112,6 +112,21 @@ tests:
|
||||
dependencies:
|
||||
- crm
|
||||
- hspec
|
||||
- singletons-base
|
||||
- text
|
||||
when:
|
||||
- condition: false
|
||||
other-modules: Paths_crm
|
||||
|
||||
crm-doctests:
|
||||
source-dirs: doctest
|
||||
main: Main.hs
|
||||
ghc-options:
|
||||
- -threaded
|
||||
- -Wno-unused-packages
|
||||
dependencies:
|
||||
- crm
|
||||
- doctest-parallel
|
||||
when:
|
||||
- condition: false
|
||||
other-modules: Paths_crm
|
||||
|
@ -10,10 +10,10 @@ newtype Graph a = Graph [(a, a)]
|
||||
It has as vertices the product of the set of vertices of the initial graph.
|
||||
It has as edge from `(a1, b1)` to `(a2, b2)` if and only if there is an edge
|
||||
from `a1` to `a2` and an edge from `b1` to `b2`
|
||||
-}
|
||||
|
||||
-- >>> productGraph (Graph [('a', 'b')]) (Graph [('c', 'd')])
|
||||
-- Graph [(('a','c'),('b','d'))]
|
||||
>>> productGraph (Graph [('a', 'b')]) (Graph [('c', 'd')])
|
||||
Graph [(('a','c'),('b','d'))]
|
||||
-}
|
||||
productGraph :: Graph a -> Graph b -> Graph (a, b)
|
||||
productGraph (Graph edges1) (Graph edges2) =
|
||||
Graph $
|
||||
|
Loading…
Reference in New Issue
Block a user