-
Notifications
You must be signed in to change notification settings - Fork 844
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3982 from mihaimaruseac/mm-ghci-internal-libs
Handle internal libraries in GHCi.
- Loading branch information
Showing
14 changed files
with
132 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
test/integration/tests/3926-ghci-with-sublibraries/Main.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Control.Concurrent | ||
import Control.Monad.IO.Class | ||
import Control.Monad | ||
import Data.List | ||
import StackTest | ||
|
||
main :: IO () | ||
main = do | ||
stack ["clean"] -- to make sure we can load the code even after a clean | ||
copy "src/Lib.v1" "src/Lib.hs" | ||
copy "src-internal/Internal.v1" "src-internal/Internal.hs" | ||
forkIO fileEditingThread | ||
replThread | ||
|
||
replThread :: IO () | ||
replThread = repl [] $ do | ||
replCommand ":main" | ||
line <- replGetLine | ||
when (line /= "hello world") $ error "Main module didn't load correctly." | ||
liftIO $ threadDelay 1000000 -- wait for an edit of the internal library | ||
reloadAndTest "testInt" "42" "Internal library didn't reload." | ||
liftIO $ threadDelay 1000000 -- wait for an edit of the internal library | ||
reloadAndTest "testStr" "\"OK\"" "Main library didn't reload." | ||
|
||
fileEditingThread :: IO () | ||
fileEditingThread = do | ||
threadDelay 1000000 | ||
-- edit the internal library and return to ghci | ||
copy "src-internal/Internal.v2" "src-internal/Internal.hs" | ||
threadDelay 1000000 | ||
-- edit the internal library and end thread, returning to ghci | ||
copy "src/Lib.v2" "src/Lib.hs" | ||
|
||
reloadAndTest :: String -> String -> String -> Repl () | ||
reloadAndTest cmd exp err = do | ||
reload | ||
replCommand cmd | ||
line <- replGetLine | ||
unless (exp `isSuffixOf` line) $ error err | ||
|
||
reload :: Repl () | ||
reload = replCommand ":reload" >> loop | ||
where | ||
loop = replGetLine >>= \line -> unless ("Ok" `isInfixOf` line) loop |
2 changes: 2 additions & 0 deletions
2
test/integration/tests/3926-ghci-with-sublibraries/files/Setup.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Distribution.Simple | ||
main = defaultMain |
22 changes: 22 additions & 0 deletions
22
test/integration/tests/3926-ghci-with-sublibraries/files/files.cabal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: files | ||
version: 0.1.0.0 | ||
build-type: Simple | ||
cabal-version: >= 2.0 | ||
|
||
library | ||
hs-source-dirs: src | ||
exposed-modules: Lib | ||
build-depends: base, lib | ||
default-language: Haskell2010 | ||
|
||
library lib | ||
hs-source-dirs: src-internal | ||
exposed-modules: Internal | ||
build-depends: base | ||
default-language: Haskell2010 | ||
|
||
executable exe | ||
hs-source-dirs: src-exe | ||
main-is: Main.hs | ||
build-depends: base, files | ||
default-language: Haskell2010 |
7 changes: 7 additions & 0 deletions
7
test/integration/tests/3926-ghci-with-sublibraries/files/src-exe/Main.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Main where | ||
|
||
import Lib | ||
|
||
main :: IO () | ||
main = do | ||
putStrLn "hello world" |
1 change: 1 addition & 0 deletions
1
test/integration/tests/3926-ghci-with-sublibraries/files/src-internal/Internal.v1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module Internal where |
4 changes: 4 additions & 0 deletions
4
test/integration/tests/3926-ghci-with-sublibraries/files/src-internal/Internal.v2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Internal where | ||
|
||
testInt :: Int | ||
testInt = 42 |
3 changes: 3 additions & 0 deletions
3
test/integration/tests/3926-ghci-with-sublibraries/files/src/Lib.v1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Lib where | ||
|
||
import Internal |
6 changes: 6 additions & 0 deletions
6
test/integration/tests/3926-ghci-with-sublibraries/files/src/Lib.v2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Lib where | ||
|
||
import Internal | ||
|
||
testStr :: String | ||
testStr = "OK" |
4 changes: 4 additions & 0 deletions
4
test/integration/tests/3926-ghci-with-sublibraries/files/stack.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resolver: ghc-8.2.2 | ||
extra-deps: | ||
- stm-2.4.4.1 | ||
- mtl-2.2.1 |