Skip to content

Commit 2eb4587

Browse files
committed
test: Add test for #297
1 parent d17af5f commit 2eb4587

8 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Helper where
2+
3+
greet :: String -> IO ()
4+
greet name = do
5+
putStrLn ("Hello, " ++ name ++ "!")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module Main where
2+
3+
import Helper
4+
5+
main :: IO ()
6+
main = do
7+
putStrLn "Starting..."
8+
greet "world"
9+
putStrLn "Done."
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[1 of 4] Compiling GHC.Debugger.View.Class ( in-memory:GHC.Debugger.View.Class, interpreted )[haskell-debugger-view-in-memory]
2+
[2 of 4] Compiling Helper ( <TEMPORARY-DIRECTORY>/Helper.hs, interpreted )[main]
3+
[3 of 4] Compiling Main ( <TEMPORARY-DIRECTORY>/Main.hs, interpreted )[main]
4+
(hdb) BreakFound {changed = True, breakId = [InternalBreakpointId Main 5], sourceSpan = SourceSpan {file = "<TEMPORARY-DIRECTORY>/Main.hs", startLine = 7, endLine = 7, startCol = 3, endCol = 25}}
5+
(hdb) BreakFound {changed = True, breakId = [InternalBreakpointId Helper 4], sourceSpan = SourceSpan {file = "<TEMPORARY-DIRECTORY>/./Helper.hs", startLine = 5, endLine = 5, startCol = 3, endCol = 38}}
6+
(hdb) Stopped at breakpoint
7+
(hdb) Starting...
8+
Stopped at breakpoint
9+
(hdb) Exiting...
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
break Main.hs 7
2+
break Helper.hs 5
3+
run
4+
continue
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$HDB Main.hs -v 0 < standalone-multi-module.hdb-stdin

test/haskell/Test/Integration/Basic.hs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ basicTests =
2727
, testCase "accepts internalInterpreter launch option" internalInterpreterOption
2828
]
2929
]
30+
, testGroup "Multi-module standalone (no cabal/hie.yaml)"
31+
[ testCase "breakpoints in two modules (#297)" multiModuleStandaloneBreakpoints
32+
, testCase "breakpoints in two modules (flipped) (#297)" multiModuleStandaloneBreakpoints2
33+
]
3034
]
3135

3236
basicForConfig :: TestName -> FilePath -> FilePath -> TestTree
@@ -89,3 +93,37 @@ internalInterpreterOption =
8993
{ lcInternalInterpreter = Just True } -- TODO: Automatically run all tests with internal interpreter too?
9094
hitBreakpointWith cfg 6
9195
disconnect
96+
97+
-- | Two-module standalone project (no cabal, no hie.yaml): set a breakpoint in
98+
-- each module, run, hit the first (Main.hs), continue, hit the second (Helper.hs).
99+
-- (#297)
100+
multiModuleStandaloneBreakpoints :: Assertion
101+
multiModuleStandaloneBreakpoints =
102+
withTestDAPServer "test/integration/standalone-multi-module" [] $ \test_dir server ->
103+
withTestDAPServerClient server $ do
104+
let cfg = mkLaunchConfig test_dir "Main.hs"
105+
_ <- sync $ launchWith cfg
106+
waitFiltering_ EventTy "initialized"
107+
_ <- sync $ setLineBreakpoints test_dir "Main.hs" [7]
108+
_ <- sync $ setLineBreakpoints test_dir "Helper.hs" [5]
109+
_ <- sync configurationDone
110+
assertStoppedLocation DAP.StoppedEventReasonBreakpoint 7
111+
continueThread 0
112+
assertStoppedLocation DAP.StoppedEventReasonBreakpoint 5
113+
disconnect
114+
115+
-- | Same as above, but flip the order of the setLineBreakpoints calls (#297)
116+
multiModuleStandaloneBreakpoints2 :: Assertion
117+
multiModuleStandaloneBreakpoints2 =
118+
withTestDAPServer "test/integration/standalone-multi-module" [] $ \test_dir server ->
119+
withTestDAPServerClient server $ do
120+
let cfg = mkLaunchConfig test_dir "Main.hs"
121+
_ <- sync $ launchWith cfg
122+
waitFiltering_ EventTy "initialized"
123+
_ <- sync $ setLineBreakpoints test_dir "Helper.hs" [5]
124+
_ <- sync $ setLineBreakpoints test_dir "Main.hs" [7]
125+
_ <- sync configurationDone
126+
assertStoppedLocation DAP.StoppedEventReasonBreakpoint 7
127+
continueThread 0
128+
assertStoppedLocation DAP.StoppedEventReasonBreakpoint 5
129+
disconnect
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Helper where
2+
3+
greet :: String -> IO ()
4+
greet name = do
5+
putStrLn ("Hello, " ++ name ++ "!")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module Main where
2+
3+
import Helper
4+
5+
main :: IO ()
6+
main = do
7+
putStrLn "Starting..."
8+
greet "world"
9+
putStrLn "Done."

0 commit comments

Comments
 (0)