Skip to content

Commit 50b60ca

Browse files
bltavaresmrcjkb
andauthored
feat(neotest): expose doctests on Neotest summary window (#247)
Co-authored-by: Marc Jakobi <[email protected]> Co-authored-by: Marc Jakobi <[email protected]>
1 parent 520d88d commit 50b60ca

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [Unreleased]
1010

11+
### Added
12+
13+
- Neotest: Expose doctests in `:Neotest summary` window
14+
1115
### Fixed
1216

1317
- Testables: Run doctests when cargo-nextest is present

lua/rustaceanvim/neotest/init.lua

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,16 @@ NeotestAdapter.discover_positions = function(file_path)
184184
end
185185
sort_positions(sorted_positions)
186186

187-
if #namespaces > 0 then
188-
local file_pos = {
189-
id = file_path,
190-
name = vim.fn.fnamemodify(file_path, ':t'),
191-
type = 'file',
192-
path = file_path,
193-
range = { 0, 0, max_end_row, 0 },
194-
-- use the shortest namespace for the file runnable
195-
runnable = namespaces[#namespaces].runnable,
196-
}
197-
table.insert(sorted_positions, 1, file_pos)
198-
end
187+
local file_pos = {
188+
id = file_path,
189+
name = vim.fn.fnamemodify(file_path, ':t'),
190+
type = 'file',
191+
path = file_path,
192+
range = { 0, 0, max_end_row, 0 },
193+
-- use the shortest namespace for the file runnable
194+
runnable = #namespaces > 0 and namespaces[#namespaces].runnable or nil,
195+
}
196+
table.insert(sorted_positions, 1, file_pos)
199197

200198
return require('neotest.types.tree').from_list(sorted_positions, function(x)
201199
return x.name

lua/rustaceanvim/neotest/trans.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function M.runnable_to_position(file_path, runnable)
2727
type = 'dir'
2828
elseif vim.startswith(runnable.label, 'test-mod') then
2929
type = 'namespace'
30-
elseif vim.startswith(runnable.label, 'test') then
30+
elseif vim.startswith(runnable.label, 'test') or vim.startswith(runnable.label, 'doctest') then
3131
type = 'test'
3232
else
3333
return

0 commit comments

Comments
 (0)