Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tasty: [TestTree] without testGroup not recognised #102

Closed
mrcjkb opened this issue Jun 18, 2023 · 6 comments
Closed

tasty: [TestTree] without testGroup not recognised #102

mrcjkb opened this issue Jun 18, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@mrcjkb
Copy link
Owner

mrcjkb commented Jun 18, 2023

  • Originally reported by @Kleidukos
  • Reproduced by me

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 mrcjkb added the bug Something isn't working label Jun 18, 2023
@mrcjkb
Copy link
Owner Author

mrcjkb commented Jun 18, 2023

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.

@mrcjkb mrcjkb self-assigned this Jun 18, 2023
@Kleidukos
Copy link

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
Copy link
Owner Author

mrcjkb commented Jun 18, 2023

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
Copy link
Owner Author

mrcjkb commented Jun 18, 2023

@all-contributors please add @Kleidukos for bug

@allcontributors
Copy link
Contributor

@mrcjkb

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

@mrcjkb
Copy link
Owner Author

mrcjkb commented Jun 18, 2023

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

@mrcjkb mrcjkb closed this as completed Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants