1
- import Control.Concurrent
2
1
import Control.Monad.IO.Class
3
2
import Control.Monad
4
3
import Data.List
14
13
copy " src/Lib.v1" " src/Lib.hs"
15
14
copy " src-internal/Internal.v1" " src-internal/Internal.hs"
16
15
stack [" build" ] -- need a build before ghci at the moment, see #4148
17
- forkIO fileEditingThread
18
16
replThread
19
17
20
18
replThread :: IO ()
@@ -23,33 +21,27 @@ replThread = repl ["--ghci-options=-ignore-dot-ghci"] $ do
23
21
-- otherwise, on Windows from msys2-20230526, `stack repl` encounters a EOF
24
22
-- and terminates gracefully.
25
23
replCommand " :main"
24
+ liftIO $ putStrLn " Awaiting prompt..."
26
25
nextPrompt
26
+ liftIO $ putStrLn " Initial prompt received"
27
27
line <- replGetLine
28
28
let expected = " hello world"
29
29
when (line /= expected) $
30
30
error $
31
31
" Main module didn't load correctly.\n "
32
32
<> " Expected: " <> expected <> " \n "
33
33
<> " Actual : " <> line <> " \n "
34
- liftIO $ threadDelay 1000000 -- wait for an edit of the internal library
34
+ liftIO $ copy " src- internal/Internal.v2 " " src-internal/Internal.hs "
35
35
reloadAndTest " testInt" " 42" " Internal library didn't reload."
36
- liftIO $ threadDelay 1000000 -- wait for an edit of the internal library
36
+ liftIO $ copy " src/Lib.v2 " " src/Lib.hs "
37
37
reloadAndTest " testStr" " \" OK\" " " Main library didn't reload."
38
38
39
- fileEditingThread :: IO ()
40
- fileEditingThread = do
41
- threadDelay 1000000
42
- -- edit the internal library and pure to ghci
43
- copy " src-internal/Internal.v2" " src-internal/Internal.hs"
44
- threadDelay 1000000
45
- -- edit the internal library and end thread, returning to ghci
46
- copy " src/Lib.v2" " src/Lib.hs"
47
-
48
39
reloadAndTest :: String -> String -> String -> Repl ()
49
40
reloadAndTest cmd exp err = do
50
41
reload
51
42
replCommand cmd
52
43
line <- replGetLine
44
+ liftIO . putStrLn $ line
53
45
unless (exp `isSuffixOf` line) $ error err
54
46
55
47
reload :: Repl ()
0 commit comments