Skip to content

Commit 1a34314

Browse files
committed
initial commit
0 parents  commit 1a34314

36 files changed

+2572
-0
lines changed

.busted

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
return {
2+
_all = {
3+
coverage = false,
4+
lpath = "lua/?.lua;lua/?/init.lua",
5+
lua = "nlua",
6+
},
7+
default = {
8+
verbose = true,
9+
},
10+
tests = {
11+
verbose = true,
12+
},
13+
}

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*.lua]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true

.github/workflows/luarocks.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
name: Push to Luarocks
3+
4+
on:
5+
push:
6+
tags:
7+
- "*"
8+
release:
9+
types:
10+
- created
11+
tags:
12+
- "*"
13+
pull_request: # Tests installing the generated rockspec on PR without uploading
14+
workflow_dispatch:
15+
16+
jobs:
17+
luarocks-upload:
18+
runs-on: ubuntu-22.04
19+
steps:
20+
- uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0 # Required to count the commits
23+
- name: Get Version
24+
run: echo "LUAROCKS_VERSION=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV
25+
26+
# Needed to install the tree-sitter parser dependency
27+
- name: Install C/C++ Compiler
28+
uses: rlalik/setup-cpp-compiler@master
29+
with:
30+
compiler: clang-latest
31+
- name: Install tree-sitter CLI
32+
uses: baptiste0928/cargo-install@v3
33+
with:
34+
crate: tree-sitter-cli
35+
36+
- name: LuaRocks Upload
37+
uses: nvim-neorocks/luarocks-tag-release@v7
38+
env:
39+
LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}
40+
with:
41+
version: ${{ env.LUAROCKS_VERSION }}
42+
dependencies: |
43+
neotest
44+
tree-sitter-c_sharp
45+
tree-sitter-fsharp

.github/workflows/main.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: main
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
types: [opened, synchronize]
7+
concurrency:
8+
group: github.head_ref
9+
cancel-in-progress: true
10+
jobs:
11+
lint:
12+
runs-on: ubuntu-latest
13+
name: lint
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: JohnnyMorganz/stylua-action@v2
17+
with:
18+
token: ${{ secrets.GITHUB_TOKEN }}
19+
version: latest
20+
args: --check .
21+
22+
tests:
23+
needs:
24+
- lint
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 6
27+
strategy:
28+
matrix:
29+
os: [ubuntu-latest, macos-latest, windows-latest]
30+
neovim_version: ["v0.10.0"]
31+
include:
32+
- os: ubuntu-latest
33+
neovim_version: "nightly"
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
- uses: actions/setup-dotnet@v4
38+
with:
39+
dotnet-version: "9.0.x"
40+
41+
- name: Install C/C++ Compiler
42+
uses: rlalik/setup-cpp-compiler@master
43+
with:
44+
compiler: clang-latest
45+
46+
- name: Install tree-sitter CLI
47+
uses: baptiste0928/cargo-install@v3
48+
with:
49+
crate: tree-sitter-cli
50+
51+
- name: Run tests
52+
id: test
53+
uses: nvim-neorocks/nvim-busted-action@v1
54+
with:
55+
nvim_version: ${{ matrix.neovim_version }}
56+
57+
- name: Save neotest log
58+
if: always() && steps.test.outcome == 'failure'
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: neotest-log-${{ matrix.neovim_version }}-${{ matrix.os }}
62+
path: ~/.local/state/nvim/neotest.log

.gitignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Compiled Lua sources
2+
luac.out
3+
4+
# luarocks build files
5+
*.src.rock
6+
*.zip
7+
*.tar.gz
8+
9+
# Object files
10+
*.o
11+
*.os
12+
*.ko
13+
*.obj
14+
*.elf
15+
16+
# Precompiled Headers
17+
*.gch
18+
*.pch
19+
20+
# Libraries
21+
*.lib
22+
*.a
23+
*.la
24+
*.lo
25+
*.def
26+
*.exp
27+
28+
# Shared objects (inc. Windows DLLs)
29+
*.dll
30+
*.so
31+
*.so.*
32+
*.dylib
33+
34+
# Executables
35+
*.exe
36+
*.out
37+
*.app
38+
*.i*86
39+
*.x86_64
40+
*.hex
41+
42+
# Test dependencies
43+
deps/
44+
**/obj/*
45+
/luarocks
46+
/lua_modules
47+
/.luarocks
48+
49+
obj/
50+
bin/

.luacheckrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ignore = {
2+
"631", -- max_line_length
3+
"122", -- read-only field of global variable
4+
}
5+
read_globals = {
6+
"vim",
7+
"describe",
8+
"it",
9+
"assert",
10+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Nikolaj Sidorenco
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# we disable the `all` command because some external tool might run it automatically
2+
.SUFFIXES:
3+
4+
all:
5+
6+
# runs all the test files.
7+
test:
8+
luarocks test --local
9+
10+
# performs a lint check and fixes issue if possible, following the config in `stylua.toml`.
11+
lint:
12+
stylua .

README.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<p align="center">
2+
<a href="https://github.com/nsidorenco/neotest-vstest/releases">
3+
<img alt="GitHub release (latest SemVer)" src="https://img.shields.io/github/v/release/nsidorenco/neotest-vstest?style=for-the-badge">
4+
</a>
5+
<a href="https://luarocks.org/modules/nsidorenco/neotest-vstest">
6+
<img alt="LuaRocks Package" src="https://img.shields.io/luarocks/v/nsidorenco/neotest-vstest?logo=lua&color=purple&style=for-the-badge">
7+
</a>
8+
</p>
9+
10+
# Neotest .NET
11+
12+
Neotest adapter for dotnet tests
13+
14+
- Integrates with the VSTest runner to support all testing frameworks.
15+
- DAP strategy for attaching debug adapter to test execution.
16+
- Supports both C# and F# projects.
17+
- Fine-grained test discovery and execution allowing running individual parameterized tests.
18+
19+
# Pre-requisites
20+
21+
neotest-vstest requires makes a number of assumptions about your environment:
22+
23+
1. The `dotnet sdk`, and the `dotnet` cli executable in the users runtime path.
24+
2. (For Debugging) `netcoredbg` is installed and `nvim-dap` plugin has been configured for `netcoredbg` (see debug config for more details)
25+
3. Requires treesitter parser for either `C#` or `F#`
26+
4. `neovim v0.10.0` or later
27+
28+
# Installation
29+
30+
## [lazy.nvim](https://github.com/folke/lazy.nvim)
31+
32+
```
33+
use({
34+
"nvim-neotest/neotest",
35+
requires = {
36+
{
37+
"nsidorenco/neotest-vstest",
38+
},
39+
}
40+
})
41+
```
42+
43+
# Usage
44+
45+
```lua
46+
require("neotest").setup({
47+
adapters = {
48+
require("neotest-vstest")
49+
}
50+
})
51+
```
52+
53+
Additional configuration settings can be provided:
54+
55+
```lua
56+
require("neotest").setup({
57+
adapters = {
58+
require("neotest-vstest")({
59+
-- Path to dotnet sdk path.
60+
-- Used in cases where the sdk path cannot be auto discovered.
61+
sdk_path = "/usr/local/dotnet/sdk/9.0.101/",
62+
-- table is passed directly to DAP when debugging tests.
63+
dap_settings = {
64+
adapter = "netcoredbg",
65+
}
66+
})
67+
}
68+
})
69+
```
70+
71+
# Debugging adapter
72+
73+
- Install `netcoredbg` to a location of your choosing and configure `nvim-dap` to point to the correct path
74+
75+
This adapter uses that standard dap strategy in `neotest`. Run it like so:
76+
77+
- `lua require("neotest").run.run({strategy = "dap"})`
78+
79+
# Contributing
80+
81+
Any help on this plugin would is much appreciated.
82+
83+
## First steps
84+
85+
If you have a use case that the adapter isn't quite able to cover, a more detailed understanding of why can be achieved by following these steps:
86+
87+
1. Setting the `loglevel` property in your `neotest` setup config to `1` to reveal all the debug logs from neotest-vstest
88+
2. Open up your tests file and do what your normally do to run the tests
89+
3. Look through the neotest log files for logs prefixed with `neotest-vstest` (can be found by running the command `echo stdpath("log")`)
90+
4. You should be able to piece together how the nodes in the neotest summary window are created (Using logs from tests that are "Found")
91+
92+
The general flow for test discovery and execution is as follows:
93+
94+
1. Spawn VSTest instance at start-up.
95+
2. On test discovery: Send list of files to VSTest instance.
96+
- Once tests have been discovered the VSTest instance will write the discovered test cases to a file.
97+
3. Read result file and parse tests.
98+
4. Use treesitter to determine line ranges for test cases.
99+
5. On test execution: Send list of test ids to VSTest instance.
100+
- Once test results are in the VSTest instance will write the results to a file.
101+
6. Read test result file and parse results.
102+
103+
## Running tests
104+
105+
To run the tests from CLI, make sure that `luarocks` is installed and executable.
106+
Then, Run `luarocks test` from the project root.
107+
108+
If you see a module 'busted.runner' not found error you need to update your `LUA_PATH`:
109+
110+
```sh
111+
eval $(luarocks path --no-bin)
112+
```

lazy.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
return {
2+
"nsidorenco/neotest-vstest",
3+
dependencies = {
4+
"nvim-neotest/neotest",
5+
},
6+
}

0 commit comments

Comments
 (0)