8 |
9 | 
10 |
11 |
12 | ## 🔧 Installation
13 |
14 | It requires [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)
15 | >Make sure you have the bash parser installed. Use `:TSInstall bash`
16 |
17 | [vim-plug](https://github.com/junegunn/vim-plug)
18 | ```vim
19 | Plug 'rcasia/neotest-bash'
20 | ```
21 |
22 | > **NOTE**: this plugin expects the `bashunit` binary to be in `./lib/bashunit`.
23 |
24 | ## ⚙ Configuration
25 | ```lua
26 | require("neotest").setup({
27 | adapters = {
28 | require("neotest-bash")
29 | }
30 | })
31 | ```
32 |
--------------------------------------------------------------------------------
/lua/neotest-bash/core/dir_filter.lua:
--------------------------------------------------------------------------------
1 | DirFilter = {}
2 |
3 | ---Filter directories when searching for test files
4 | ---@async
5 | ---@param name string Name of directory
6 | ---@param rel_path string Path to directory, relative to root
7 | ---@param root string Root directory of project
8 | ---@return boolean
9 | function DirFilter.filter_dir(name, rel_path, root)
10 | return true
11 | end
12 |
13 | return DirFilter
14 |
--------------------------------------------------------------------------------
/lua/neotest-bash/core/file_checker.lua:
--------------------------------------------------------------------------------
1 | FileChecker = {}
2 |
3 | ---@async
4 | ---@param file_path string
5 | ---@return boolean
6 | function FileChecker.isTestFile(file_path)
7 | -- test files end with test.sh
8 | return file_path:match("test.sh$")
9 | end
10 |
11 | return FileChecker
12 |
--------------------------------------------------------------------------------
/lua/neotest-bash/core/positions_discoverer.lua:
--------------------------------------------------------------------------------
1 | local lib = require("neotest.lib")
2 |
3 | PositionsDiscoverer = {}
4 |
5 | ---Given a file path, parse all the tests within it.
6 | ---@async
7 | ---@param file_path string Absolute file path
8 | ---@return neotest.Tree | nil
9 | function PositionsDiscoverer.discover_positions(file_path)
10 | local query = [[
11 | (function_definition
12 | name: (word) @test.name
13 | (#match? @test.name "^test_")
14 | ) @test.definition
15 | ]]
16 |
17 | return lib.treesitter.parse_positions(file_path, query)
18 | end
19 |
20 | return PositionsDiscoverer
21 |
--------------------------------------------------------------------------------
/lua/neotest-bash/core/result_builder.lua:
--------------------------------------------------------------------------------
1 | local ResultList = require("neotest-bash.util.result_list")
2 |
3 | ResultBuilder = {}
4 |
5 | ---@async
6 | ---@param spec neotest.RunSpec
7 | ---@param result neotest.StrategyResult
8 | ---@param tree neotest.Tree
9 | ---@return table