phoityne / hdx4vsc

Haskell Debugger Extension for Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=phoityne.phoityne-vscode
BSD 3-Clause "New" or "Revised" License
50 stars 9 forks source link

Debugger runs through only one spec file #21

Closed victor-shneer closed 2 years ago

victor-shneer commented 2 years ago

If I run stack test I got

haskell-step-by-step> test (suite: haskell-step-by-step-test)

Chapter_1.NumberOfChars
  charCount
    with "123"
      should be 3

Chapter_1.NumberOfWords
  wordCount
    with "first second third"
      should be 3

Chapter_2.LastButOne
  lastButOne
    with "123"
      should be 2
Chapter_4.AsIntFold
  Str as Int 
    with "-3"
      should be -3
Phoityne.Example.Math
  sumGs
    with [1..10]
      should be 55
    with [10..1]
      should be 55
    with [1..1]
      should be 0

Finished in 0.0043 seconds
7 examples, 0 failures

But if I run debugger I got only 3 examples. This is my debugger output

Configuration read.
Starting GHCi.
Wait for a moment.

CWD: /Users/testuser/Documents/haskell-learn/first-touch
CMD: stack ghci --with-ghc=ghci-dap --test --no-load --no-build --main-is TARGET --ghci-options -fprint-evld-with-show

Now, waiting for an initial prompt("> ") from ghci.

The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: haskell-step-by-step
[DAP][INFO] start ghci-dap-0.0.17.0.
GHCi, version 9.0.2: https://www.haskell.org/ghc/  :? for help
ghci>:set prompt "<<DAP_CMD_END2>>\nH>>= "
H>>= :set prompt-cont "<<DAP_CMD_END2>>\nH>>= "
H>>= :dap-launch ...
H>>= :load /Users/testuser/Documents/haskell-learn/first-touch/test/Spec.hs

<no location info>: warning: [-Wmissing-home-modules]
    Modules are not listed in command line but needed for compilation: 
        Chapter_1.NumberOfCharsInAFile
        Chapter_1.NumberOfCharsSpec
        Chapter_1.NumberOfWordsInAFile
        Chapter_1.NumberOfWordsSpec
        Chapter_2.LastButOne
        Chapter_2.LastButOneSpec
        Chapter_4.AsIntFoldSpec
        Chapter_4.FoldExercises
        Phoityne.Example.Math
        Phoityne.Example.MathSpec
        SpecHelper
[ 1 of 12] Compiling Chapter_1.NumberOfCharsInAFile ( /Users/testuser/Documents/haskell-learn/first-touch/src/Chapter_1/NumberOfCharsInAFile.hs, interpreted )
[ 2 of 12] Compiling Chapter_1.NumberOfWordsInAFile ( /Users/testuser/Documents/haskell-learn/first-touch/src/Chapter_1/NumberOfWordsInAFile.hs, interpreted )
[ 3 of 12] Compiling Chapter_2.LastButOne ( /Users/testuser/Documents/haskell-learn/first-touch/src/Chapter_2/LastButOne.hs, interpreted )
[ 4 of 12] Compiling Chapter_4.FoldExercises ( /Users/testuser/Documents/haskell-learn/first-touch/src/Chapter_4/FoldExercises.hs, interpreted )
[ 5 of 12] Compiling Phoityne.Example.Math ( /Users/testuser/Documents/haskell-learn/first-touch/src/Phoityne/Example/Math.hs, interpreted )
[ 6 of 12] Compiling SpecHelper       ( /Users/testuser/Documents/haskell-learn/first-touch/test/SpecHelper.hs, interpreted )
[ 7 of 12] Compiling Phoityne.Example.MathSpec ( /Users/testuser/Documents/haskell-learn/first-touch/test/Phoityne/Example/MathSpec.hs, interpreted )
[ 8 of 12] Compiling Chapter_4.AsIntFoldSpec ( /Users/testuser/Documents/haskell-learn/first-touch/test/Chapter_4/AsIntFoldSpec.hs, interpreted )
[ 9 of 12] Compiling Chapter_2.LastButOneSpec ( /Users/testuser/Documents/haskell-learn/first-touch/test/Chapter_2/LastButOneSpec.hs, interpreted )
[10 of 12] Compiling Chapter_1.NumberOfWordsSpec ( /Users/testuser/Documents/haskell-learn/first-touch/test/Chapter_1/NumberOfWordsSpec.hs, interpreted )
[11 of 12] Compiling Chapter_1.NumberOfCharsSpec ( /Users/testuser/Documents/haskell-learn/first-touch/test/Chapter_1/NumberOfCharsSpec.hs, interpreted )
[12 of 12] Compiling Main             ( /Users/testuser/Documents/haskell-learn/first-touch/test/Spec.hs, interpreted )
Ok, 12 modules loaded.
H>>= :dap-context-modules ...
H>>= :dap-set-breakpoints ...
Breakpoint 0 activated at /Users/testuser/Documents/haskell-learn/first-touch/src/Chapter_4/FoldExercises.hs:37:53-96
No breakpoints found at that location.
Breakpoint 1 activated at /Users/testuser/Documents/haskell-learn/first-touch/src/Chapter_4/FoldExercises.hs:39:44-58
H>>= :dap-set-function-breakpoints ...
H>>= :dap-continue ...

sumGs
  with [1..10]
    should be 55
  with [10..1]
    should be 55
  with [1..1]
    should be 0

Finished in 0.0019 seconds
3 examples, 0 failures
H>>= 
debugging completed. 
:quit
Leaving GHCi.

So it is missing my breakpoints from other test files. My Spec.hs file looks like this: {-# OPTIONS_GHC -F -pgmF hspec-discover #-}

I see in the debugger output that he sees all my modules and test files but for some reason he finishes his work after passing through only one of test file. If I delete this file, he takes the next one and skip others.. I even see messages in the debugger output like "Breakpoint 0 activated at.." from files that will be skipped. What am I missing here? Thanks!

My launch.json config is

"version": "0.2.0",
  "configurations": [

    {
      "type": "ghc",
      "request": "launch",
      "name": "haskell(stack)",
      "internalConsoleOptions": "openOnSessionStart",
      "workspace": "${workspaceFolder}",
      "startup": "${workspaceFolder}/test/Spec.hs",
      "startupFunc": "",
      "startupArgs": "",
      "stopOnEntry": false,
      "mainArgs": "",
      "ghciPrompt": "H>>= ",
      "ghciInitialPrompt": "> ",
      "ghciCmd": "stack ghci --test --no-load --no-build --main-is TARGET --ghci-options -fprint-evld-with-show",
      "ghciEnv": {},
      "logFile": "${workspaceFolder}/.vscode/phoityne.log",
      "logLevel": "WARNING",
      "forceInspect": false
    },
phoityne commented 2 years ago

Hi. I saw your github code. I think it will work if you remove the main function in each spec file. (Spec.hs automatically generates the main function.)

Regards.