mrcjkb / neotest-haskell

Neotest adapter for Haskell (cabal or stack) with support for Sydtest, Hspec and Tasty
GNU General Public License v2.0
55 stars 4 forks source link

"No tests found" with hspec #185

Closed prescientmoon closed 2 months ago

prescientmoon commented 2 months ago

Neovim version (nvim -v)

v0.10.1

Operating system/version

NixOS 24.05

How to reproduce the issue

This is my test file

{-# LANGUAGE QuasiQuotes #-}

module Tests.Server.ColumnsSpec (main) where

...
import Test.Hspec (SpecWith, before_, it, pendingWith, shouldBe)
...

main :: SpecWith ()
main = do
  void $ before_ populateMainServerDb $ do
    it "supports creating a new single select column" $ do
      ...

Expected behaviour

The test should run when my cursor is over the it

Actual behaviour

"No tests found" is printed instead

A minimal Neovim config used to reproduce this issue.

This is the relevant section:

require("neotest-haskell")({
  build_tools = {
    "stack",
  },
  frameworks = {
    "hspec",
  },
}),
mrcjkb commented 2 months ago

hey 👋

thanks for reporting.

A minimal Neovim config used to reproduce this issue.

By this, I mean a full minimal config, without other plugins that could potentially interfere with this one. This is required so that I don't spend time trying to reproduce issues that may be caused by another plugin or a misconfiguration.

I don't provide a template with this repository yet, but you can use this one as an example. It just needs to be adapted to use neotest with this adapter and the tree-sitter-haskell parser.

P.S. I'm on vacation right now so I may be slow to respond.

prescientmoon commented 2 months ago

@mrcjkb Here's a config that reproduces the issue:

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
    spec = {
        {
            config = function()
                require("neotest").setup({
                    require("neotest-haskell")({
                        build_tools = {
                            "stack",
                        },
                        frameworks = {
                            "hspec",
                        },
                    }),
                })
            end,
            dependencies = {
                "mrcjkb/neotest-haskell",
                "nvim-lua/plenary.nvim",
                {
                    dir = "/nix/store/m0fnisxcjbf34xqmcj0i7nw5nkdla1nv-treesitter-with-parsers",
                },
                "nvim-neotest/nvim-nio",
            },
            name = "neotest",
            "nvim-neotest/neotest",
        },
    },
})

Load the config with nvim -u config.lua Spec.hs, where Spec.hs is the following file:

{-# LANGUAGE QuasiQuotes #-}

module Tests.Server.ColumnsSpec (main) where

import Test.Hspec (Spec, before_, describe, it, pendingWith, shouldBe)

main :: Spec
main = do
  void $ before_ populateMainServerDb $ do
    it "supports creating a new single select column" $ do
      pure ()

The treesitter is taken from nixpkgs so I do not have to build the parsers locally. The expression for it is something like:

pkgs.symlinkJoin {
  name = "treesitter-with-parsers";
  paths = [
    pkgs.vimPlugins.nvim-treesitter.withAllGrammars
    pkgs.vimPlugins.nvim-treesitter.withAllGrammars.dependencies
  ];
}

The checkhealth does pass, so the haskell parser is indeed there I think.

mrcjkb commented 2 months ago

Here's your probem:

require("neotest").setup({
  require("neotest-haskell")({
    build_tools = {
      "stack",
    },
    frameworks = {
      "hspec",
    },
  }),
})

should be

require("neotest").setup({
  adapters = {
    require("neotest-haskell")({
      build_tools = {
        "stack",
      },
      frameworks = {
        "hspec",
      },
    }),
  },
})
prescientmoon commented 2 months ago

@mrcjkb OMG, thank you so much <3