nvim-neotest / neotest

An extensible framework for interacting with tests within NeoVim.
MIT License
2.26k stars 110 forks source link

[BUG] test discovery is wrong when running NTestRunNearest #242

Open duguyue100 opened 1 year ago

duguyue100 commented 1 year ago

NeoVim Version Output of nvim --version

NVIM v0.9.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-10 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -fno-common -Wno-unused-result -Wimplicit-fallthrough -fdiagnostics-color=always -fstack-protector-strong -DUNIT_TESTING -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/__w/neovim/neovim/.deps/usr/include/luajit-2.1 -I/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/build/src/nvim/auto -I/__w/neovim/neovim/build/include -I/__w/neovim/neovim/build/cmake.config -I/__w/neovim/neovim/src -I/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/.deps/usr/include

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/__w/neovim/neovim/build/nvim.AppDir/usr/share/nvim"

Run :checkhealth for more info

Describe the bug A clear and concise description of what the bug is.

As shown in the following image, when running NetstRunNearest, after it's finished, the checkmark is actually not at the line of the test function, but the one above. At first, I thought this is a misalignment, but later I found out that this actually runs the test above this one.

image

To Reproduce

This is all I have for configuring neotest

" === NeoTest ===
let test#python#pytest#options = "--color=yes"
command NTestRun :lua require("neotest").run.run(vim.fn.expand("%"))
command NTestRunNearest :lua require("neotest").run.run()
command NTestStopNearest :lua require("neotest").run.stop()
command NTestSummaryOpen :lua require("neotest").summary.open()
command NTestSummaryClose :lua require("neotest").summary.close()
command NTestSummaryToggle :lua require("neotest").summary.toggle()
command NTestOutput :lua require("neotest").output.open({ enter = true })

Expected behavior A clear and concise description of what you expected to happen.

The checkmark at the test function line and actually run the correct test.

duguyue100 commented 1 year ago

Also, here is my setup

require("neotest").setup({
  diagnostic = {
    enabled = true
  },
  adapters = {
    require("neotest-vim-test")({ allow_file_types = { "python" } }),
  },

  highlights = {
    passed = "NeotestPassed",
    running = "NeotestRunning",
    failed = "NeotestFailed",
    skipped = "NeotestSkipped",
    test = "NeotestTest",
    namespace = "NeotestNamespace",
    focused = "NeotestFocused",
    file = "NeotestFile",
    dir = "NeotestDir",
    border = "NeotestBorder",
    indent = "NeotestIndent",
    expand_marker = "NeotestExpandMarker",
    adapter_name = "NeotestAdapterName",
    select_win = "NeotestWinSelect",
    marked = "NeotestMarked",
  },

  icons = {
    expanded = "",
    collapsed = "",
    passed = "✅",
    running = "✨",
    failed = "❌",
    unknown = "❔",
  },
})
rcarriga commented 1 year ago

I can't reproduce so I'm not sure what the issue is. Does using neotest-python have any effect?