Skip to content

Commit

Permalink
Add tests for multiple source dirs and multiple libraries, nmattia#92.
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Nov 9, 2018
1 parent 90e27fc commit e3d2b1d
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/multiple/app/Foo.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import qualified Bar

main :: IO ()
main = Bar.main
5 changes: 5 additions & 0 deletions tests/multiple/golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1
2
3
4
5
9 changes: 9 additions & 0 deletions tests/multiple/lib1/FooBar.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module FooBar where

import Conduit

spitOut :: ConduitT () Int IO ()
spitOut = yieldMany [ 1 ..]

digest :: ConduitT Int Void IO ()
digest = mapM_C print
7 changes: 7 additions & 0 deletions tests/multiple/lib2/Bar.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Bar where

import Conduit
import FooBar

main :: IO ()
main = runConduit $ spitOut .| takeC 5 .| digest
22 changes: 22 additions & 0 deletions tests/multiple/package-pkg-name-12.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: snack-multiple-test

library:
name: lib1
source-dirs: lib1
dependencies:
- conduit

library:
name: lib2
source-dirs: lib2
dependencies:
- conduit
- lib1

executable:
main: Foo.hs
source-dirs: app
dependencies:
- conduit
- lib1
- lib2
22 changes: 22 additions & 0 deletions tests/multiple/package-pkg-name-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: snack-multiple-test

library:
# NOTE: Inherits the package's name.
source-dirs: lib1
dependencies:
- conduit

library:
name: lib2
source-dirs: lib2
dependencies:
- conduit
- snack-multiple-test

executable:
main: Foo.hs
source-dirs: app
dependencies:
- conduit
- snack-multiple-test
- lib2
15 changes: 15 additions & 0 deletions tests/multiple/package-pkg.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
let
lib1 =
{ src = lib1;
dependencies = [ "conduit" ];
};
lib2 =
{ src = lib2;
dependencies = [ "conduit" ];
};
in
{ main = "Foo";
src = ./app;
dependencies = [ "conduit" ];
packages = [ lib1 lib2 ];
}
4 changes: 4 additions & 0 deletions tests/multiple/package-src.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ main = "Foo";
src = [ ./lib1 ./lib2 ./app ];
dependencies = [ "conduit" ];
}
11 changes: 11 additions & 0 deletions tests/multiple/package-src.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: snack-multiple-test

dependencies:
- conduit

executable:
main: Foo.hs
source-dirs:
- app
- lib1
- lib2
31 changes: 31 additions & 0 deletions tests/multiple/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# vim: ft=sh sw=2 et

set -euo pipefail

test() {
$SNACK build
$SNACK run | diff golden -

TMP_FILE=$(mktemp)

capture_io "$TMP_FILE" main | $SNACK ghci

diff golden $TMP_FILE
rm $TMP_FILE
}

# TODO: Fix cannot coerce a list to a string, at /...-snack-lib/files.nix:66:12
SNACK="snack -j4 -s ./package-src.nix" test

# TODO: Fix cannot coerce a list to a string, at /...-snack-lib/hpack.nix:60:37
SNACK="snack -j4 -p ./package-src.yaml" test

# TODO: Fix cannot coerce a set to a string, at /...-snack-lib/files.nix:66:12
SNACK="snack -j4 -s ./package-pkg.nix" test

# TODO: Fix attribute 'lib2' missing, at /...-snack-lib/default.nix:22:18
SNACK="snack -j4 -p ./package-pkg-name-2.yaml" test

# TODO: Fix attribute 'lib1' missing, at /...-snack-lib/default.nix:22:18
SNACK="snack -j4 -p ./package-pkg-name-12.yaml" test

0 comments on commit e3d2b1d

Please sign in to comment.