mrcjkb / neotest-haskell

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

tasty: `[TestTree]` without `testGroup` not recognised #102

Closed mrcjkb closed 1 year ago

mrcjkb commented 1 year ago

Neovim version (nvim -v)

nightly

Operating system/version

NixOS 23.05

How to reproduce the issue

Place cursor on the function's type signature (test file:

stage1Tests :: [TestTree]
stage1Tests =
  [ testCase "Multi-digit return" testMultiDigitReturn
  , testCase "Bunch of newlines" testBunchOfNewlines
  , testCase "No newlines" testNoNewlines
  , testCase "Missing closing paren" testMissingClosingParen
  , testCase "Missing return value" testMissingReturnValue
  , testCase "Missing closing brace" testMissingClosingBrace
  ]

and run neotest

Expected behaviour

neotest runs all tests within the [TestTree] and outputs the results as virtual text

Actual behaviour

neotest tries to run all tests and outputs an error message. This is because neotest-haskell can't find any test groups and passes -p $0~ with no paths to match.

A minimal Neovim config used to reproduce this issue.

require('neotest').setup {
      adapters = {
        require('neotest-haskell'),
      },
}
mrcjkb commented 1 year ago

There are two things that need to be fixed:

  1. Do not use the -p option if no matches are found.
  2. Add support for detecting function :: [TestTree] as a neotest namespace.
Kleidukos commented 1 year ago

Do you think tree-sitter could be able to walk up the tree of nodes and detect the testGroup that's just up ahead of the function that defines the list of tests?

mrcjkb commented 1 year ago

Do you think tree-sitter could be able to walk up the tree of nodes and detect the testGroup that's just up ahead of the function that defines the list of tests?

I would have to add some queries to tasty-positions.scm for that. It should be possible, but IIRC, I tried that once and it broke a bunch of other stuff, so I gave up on it. I will look into it again later.

For now, #104 implements a hotfix by adding -p arguments for each top-level testCase when running all tests in a file.

mrcjkb commented 1 year ago

@all-contributors please add @Kleidukos for bug

allcontributors[bot] commented 1 year ago

@mrcjkb

I've put up a pull request to add @Kleidukos! :tada:

mrcjkb commented 1 year ago

Closing this as fixed by #104 and opened #107 for the more complicated query enhancement.