diff --git a/tests/multiple/app/Foo.hs b/tests/multiple/app/Foo.hs new file mode 100644 index 0000000..bfe5d3c --- /dev/null +++ b/tests/multiple/app/Foo.hs @@ -0,0 +1,4 @@ +import qualified Bar + +main :: IO () +main = Bar.main diff --git a/tests/multiple/golden b/tests/multiple/golden new file mode 100644 index 0000000..8a1218a --- /dev/null +++ b/tests/multiple/golden @@ -0,0 +1,5 @@ +1 +2 +3 +4 +5 diff --git a/tests/multiple/lib1/FooBar.hs b/tests/multiple/lib1/FooBar.hs new file mode 100644 index 0000000..78abe00 --- /dev/null +++ b/tests/multiple/lib1/FooBar.hs @@ -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 diff --git a/tests/multiple/lib2/Bar.hs b/tests/multiple/lib2/Bar.hs new file mode 100644 index 0000000..d499526 --- /dev/null +++ b/tests/multiple/lib2/Bar.hs @@ -0,0 +1,7 @@ +module Bar where + +import Conduit +import FooBar + +main :: IO () +main = runConduit $ spitOut .| takeC 5 .| digest diff --git a/tests/multiple/package-pkg-name-12.yaml b/tests/multiple/package-pkg-name-12.yaml new file mode 100644 index 0000000..59ef765 --- /dev/null +++ b/tests/multiple/package-pkg-name-12.yaml @@ -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 diff --git a/tests/multiple/package-pkg-name-2.yaml b/tests/multiple/package-pkg-name-2.yaml new file mode 100644 index 0000000..cc5a0c3 --- /dev/null +++ b/tests/multiple/package-pkg-name-2.yaml @@ -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 diff --git a/tests/multiple/package-pkg.nix b/tests/multiple/package-pkg.nix new file mode 100644 index 0000000..4809c11 --- /dev/null +++ b/tests/multiple/package-pkg.nix @@ -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 ]; + } diff --git a/tests/multiple/package-src.nix b/tests/multiple/package-src.nix new file mode 100644 index 0000000..d322850 --- /dev/null +++ b/tests/multiple/package-src.nix @@ -0,0 +1,4 @@ +{ main = "Foo"; + src = [ ./lib1 ./lib2 ./app ]; + dependencies = [ "conduit" ]; +} diff --git a/tests/multiple/package-src.yaml b/tests/multiple/package-src.yaml new file mode 100644 index 0000000..1052683 --- /dev/null +++ b/tests/multiple/package-src.yaml @@ -0,0 +1,11 @@ +name: snack-multiple-test + +dependencies: + - conduit + +executable: + main: Foo.hs + source-dirs: + - app + - lib1 + - lib2 diff --git a/tests/multiple/test b/tests/multiple/test new file mode 100755 index 0000000..8141ca9 --- /dev/null +++ b/tests/multiple/test @@ -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