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

Unexpected argument $0~/parsing/' #75

Closed
bartoszluka opened this issue Apr 6, 2023 · 6 comments
Closed

Unexpected argument $0~/parsing/' #75

bartoszluka opened this issue Apr 6, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@bartoszluka
Copy link

Neovim version (nvim -v)

v0.9.0-dev-1347+gfd32a9875

Operating system/version

Arch btw

How to reproduce the issue

  1. go to Spec.hs
  2. place cursor on the first line of tests (describe "parsing" $ do)
  3. run lua require("neotest").run.run()
  4. get the following error
seal> test (suite: seal-test, args: -p $0~/parsing/)

seal-test: unexpected argument `$0~/parsing/'
Try `seal-test --help' for more information.

seal> Test suite seal-test failed
Test suite failure for package seal-0.1.0.0
    seal-test:  exited with: ExitFailure 1
Logs printed to console

source code:
https://github.com/bartoszluka/seal/blob/aafef2ea9590db3dd77053e17eee1f5b05b40b55/test/Spec.hs#L56

Expected behaviour

Expect command to be correct: stack test --match ...

Actual behaviour

Weird $0 in the command. Also if the tests are nested it looks like this:

seal> test (suite: seal-test, args: -p $0~/parsing/&&/program/)

seal-test: unexpected argument `$0~/parsing/&&/program/'
Try `seal-test --help' for more information.

A minimal Neovim config used to reproduce this issue.

-- using lazy.nvim as a package manager
-- this is in the file neotest.lua
return {
    "nvim-neotest/neotest",
    dependencies = {
        "mrcjkb/neotest-haskell",
        "nvim-lua/plenary.nvim",
        "nvim-treesitter/nvim-treesitter",
        "antoinemadec/FixCursorHold.nvim",
    },
    cmd = "NeotestRun",
    config = function()
        require("neotest").setup({
            adapters = {
                require("neotest-haskell"),
            },
        })
    end,
}
@bartoszluka bartoszluka added the bug Something isn't working label Apr 6, 2023
@bartoszluka
Copy link
Author

bartoszluka commented Apr 6, 2023

I fixed it by using only hspec (it used tasty's arguments even though I was using hspec) in frameworks list.

return {
    "nvim-neotest/neotest",
    dependencies = {
        "mrcjkb/neotest-haskell",
        "nvim-lua/plenary.nvim",
        "nvim-neotest/neotest-plenary",
        "nvim-treesitter/nvim-treesitter",
        "antoinemadec/FixCursorHold.nvim",
    },
    cmd = "NeotestRun",
    config = function()
        require("neotest").setup({
            adapters = {
                require("neotest-haskell")({
                    build_tools = { "stack", "cabal" },
                    frameworks = {
                        "hspec",
                        -- "tasty",
                        -- "sydtest",
                    },
                }),
                require("neotest-rust"),
            },
            require("neotest-plenary"),
        })
        vim.api.nvim_create_user_command("NeotestRun", require("neotest").run.run, {})
    end,
}

@mrcjkb
Copy link
Owner

mrcjkb commented Apr 6, 2023

Hey, thanks for reporting this! Glad you were able to find a workaround.

Normally, you shouldn't have to disable the other frameworks for it to work with Hspec.
I checked out your project, but couldn't reproduce it with the default setup. It selected Hspec, as expected.
So I'll leave this issue closed for now.

Are you on the latest revision? If you use lazy.nvim, you can find that out by looking at the lock file.

For the purpose of information, this is how the framework detection works:

  • By default, it checks for the use of Test.Tasty, Test.Hspec and Test.Syd modules (in that order), using tree-sitter.
  • If it finds a Test.Tasty module, it will assume tasty is being used - which is what appeared to have happened in your case.

Test.Tasty is checked first, because tasty-hspec might result in Test.Hspec imports in a tasty test module. But the opposite is uncommon.

@bartoszluka
Copy link
Author

Yes, I am using 0.8.0 version. I didn't have any mention of "tasty" in the project so I don't know why it was picked up.

@mrcjkb
Copy link
Owner

mrcjkb commented Apr 6, 2023

Do you have any other projects that use tasty?

I'm asking in case the tree-sitter parser somehow got the contents from the wrong file and cached them.

@bartoszluka
Copy link
Author

no I haven't heard of tasty before this issue, but I'm converting this very project to tasty now

@mrcjkb
Copy link
Owner

mrcjkb commented Apr 6, 2023

That'll hopefully solve it 😁

Please let me know if you run into any issues.

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