Skip to content

Commit

Permalink
Add test cases for haskell_multi REPL
Browse files Browse the repository at this point in the history
Based on #471
  • Loading branch information
aherrmann committed Mar 14, 2019
1 parent a15d14b commit 6ab0875
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/RunTests.hs
Expand Up @@ -4,7 +4,7 @@
{-# LANGUAGE QuasiQuotes #-}

import Data.Foldable (for_)
import Data.List (isInfixOf)
import Data.List (isInfixOf, sort)
import System.Exit (ExitCode(..))

import qualified System.Process as Process
Expand Down Expand Up @@ -66,6 +66,14 @@ main = hspec $ do
it "repl flags" $ do
assertSuccess (bazel ["run", "//tests/repl-flags:repl_flags@repl", "--", "-ignore-dot-ghci", "-e", "foo"])

describe "multi_repl" $ do
it "loads transitive library dependencies" $ do
let p' (stdout, _stderr) = lines stdout == ["tests/multi_repl/bc/src/BC/C.hs"]
outputSatisfy p' (bazel ["run", "//tests/multi_repl:c_only_repl", "--", "-ignore-dot-ghci", "-e", ":show targets"])
it "loads transitive source dependencies" $ do
let p' (stdout, _stderr) = sort (lines stdout) == ["tests/multi_repl/a/src/A/A.hs","tests/multi_repl/bc/src/BC/B.hs","tests/multi_repl/bc/src/BC/C.hs"]
outputSatisfy p' (bazel ["run", "//tests/multi_repl:c_multi_repl", "--", "-ignore-dot-ghci", "-e", ":show targets"])

it "startup script" $ do
assertSuccess (safeShell [
"pwd=$(pwd)"
Expand Down
16 changes: 16 additions & 0 deletions tests/multi_repl/BUILD.bazel
@@ -0,0 +1,16 @@
load(
"@io_tweag_rules_haskell//haskell:haskell.bzl",
"haskell_repl",
)

haskell_repl(
name = "c_only_repl",
# To only load :c by source.
include = ["//tests/multi_repl/bc:c"],
deps = ["//tests/multi_repl/bc:c"],
)

haskell_repl(
name = "c_multi_repl",
deps = ["//tests/multi_repl/bc:c"],
)
17 changes: 17 additions & 0 deletions tests/multi_repl/a/BUILD.bazel
@@ -0,0 +1,17 @@
package(default_visibility = ["//visibility:public"])

load(
"@io_tweag_rules_haskell//haskell:haskell.bzl",
"haskell_library",
)

haskell_library(
name = "a",
srcs = [
"src/A/A.hs",
],
src_strip_prefix = "src",
deps = [
"//tests/hackage:base",
],
)
4 changes: 4 additions & 0 deletions tests/multi_repl/a/src/A/A.hs
@@ -0,0 +1,4 @@
module A.A ( a ) where

a :: ()
a = ()
30 changes: 30 additions & 0 deletions tests/multi_repl/bc/BUILD.bazel
@@ -0,0 +1,30 @@
package(default_visibility = ["//visibility:public"])

load(
"@io_tweag_rules_haskell//haskell:haskell.bzl",
"haskell_library",
)

haskell_library(
name = "b",
srcs = [
"src/BC/B.hs",
],
src_strip_prefix = "src",
deps = [
"//tests/hackage:base",
"//tests/multi_repl/a",
],
)

haskell_library(
name = "c",
srcs = [
"src/BC/C.hs",
],
src_strip_prefix = "src",
deps = [
":b",
"//tests/hackage:base",
],
)
6 changes: 6 additions & 0 deletions tests/multi_repl/bc/src/BC/B.hs
@@ -0,0 +1,6 @@
module BC.B ( b ) where

import A.A ( a )

b :: ()
b = a
6 changes: 6 additions & 0 deletions tests/multi_repl/bc/src/BC/C.hs
@@ -0,0 +1,6 @@
module BC.C ( c ) where

import BC.B ( b )

c :: ()
c = b

0 comments on commit 6ab0875

Please sign in to comment.