Skip to content

Commit

Permalink
Merge branch 'main' into feature/shorten-xunit-names
Browse files Browse the repository at this point in the history
  • Loading branch information
Issafalcon committed Dec 27, 2024
2 parents c4f7a6f + 256eeb5 commit 69450e5
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 30 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/luarocks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Push to Luarocks

on:
push:
tags:
- '*'
release:
types:
- created
tags:
- '*'
pull_request: # Tests installing the generated rockspec on PR without uploading
workflow_dispatch:

jobs:
luarocks-upload:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required to count the commits
- name: Get Version
run: echo "LUAROCKS_VERSION=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV

# Needed to install the tree-sitter parser dependency
- name: Install C/C++ Compiler
uses: rlalik/setup-cpp-compiler@master
with:
compiler: clang-latest
- name: Install tree-sitter CLI
uses: baptiste0928/cargo-install@v3
with:
crate: tree-sitter-cli

- name: LuaRocks Upload
uses: nvim-neorocks/luarocks-tag-release@v7
env:
LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}
with:
version: ${{ env.LUAROCKS_VERSION }}
dependencies: |
neotest
tree-sitter-c_sharp
29 changes: 8 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
name: main

on:
push:
branches: [main]
pull_request:
types: [opened, synchronize]

concurrency:
group: github.head_ref
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
name: lint
steps:
- uses: actions/checkout@v3

- uses: JohnnyMorganz/stylua-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: --check .
#documentation:
# runs-on: ubuntu-latest
# name: documentation
# steps:
# - uses: actions/checkout@v3
#

#documentation:
# runs-on: ubuntu-latest
# name: documentation
# steps:
# - uses: actions/checkout@v3
#
# - name: setup neovim
# uses: rhysd/action-setup-vim@v1
# with:
Expand All @@ -40,37 +36,30 @@ jobs:

# - name: check docs diff
# run: exit $(git diff --name-only origin/main -- doc | wc -l)

tests:
needs:
needs:
- lint
#- documentation
runs-on: ubuntu-latest
timeout-minutes: 2
strategy:
matrix:
neovim_version: ['v0.9.1', 'v0.9.4', 'v0.10.0', 'nightly']

neovim_version: ['v0.10.0', 'v0.10.1', 'v0.10.2', 'v0.10.3', 'nightly']
steps:
- uses: actions/checkout@v3

- run: date +%F > todays-date

- name: restore cache for today's nightly.
uses: actions/cache@v3
with:
path: _neovim
key: ${{ runner.os }}-x64-${{ hashFiles('todays-date') }}

- name: setup neovim
uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: ${{ matrix.neovim_version }}

- name: run tests
run: make test-ci

release:
name: release
if: ${{ github.ref == 'refs/heads/main' }}
Expand All @@ -79,13 +68,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: simple
package-name: neotest-dotnet

- name: tag stable versions
if: ${{ steps.release.outputs.release_created }}
run: |
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## [1.7.0](https://github.com/Issafalcon/neotest-dotnet/compare/v1.6.5...v1.7.0) (2024-12-27)


### Features

* **runsettings:** Adds support for runsettings files ([4c82420](https://github.com/Issafalcon/neotest-dotnet/commit/4c8242099d6c222e8340c0a09bc34df2bac81dcf))
* support luarocks/rocks.nvim ([c7ccbaa](https://github.com/Issafalcon/neotest-dotnet/commit/c7ccbaaee488c5668ccd9b6f7b889fda6344fa51))


### Bug Fixes

* add opts for legacy behavior for Quer:iter_matches ([da35fac](https://github.com/Issafalcon/neotest-dotnet/commit/da35fac262cb6bd2c7a99c7c8f3e2ecc465b9a35))
* use vim.iter():flatten() instead of deprecated vim.tbl_flatten() on 0.11+ ([a4324ce](https://github.com/Issafalcon/neotest-dotnet/commit/a4324cea9dbd13a076d31aa2fd23e0d35b4292c5))
* **workflow:** Updating supported versions ([78a3620](https://github.com/Issafalcon/neotest-dotnet/commit/78a3620c339060afed99ef7af7e76325f3f7110e))

## [1.6.5](https://github.com/Issafalcon/neotest-dotnet/compare/v1.6.4...v1.6.5) (2024-06-01)


Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
<a href="https://github.com/Issafalcon/neotest-dotnet/releases">
<img alt="GitHub release (latest SemVer)" src="https://img.shields.io/github/v/release/Issafalcon/neotest-dotnet?style=for-the-badge">
</a>
<a href="https://luarocks.org/modules/Issafalcon/neotest-dotnet">
<img alt="LuaRocks Pacakage" src="https://img.shields.io/luarocks/v/Issafalcon/neotest-dotnet?logo=lua&color=purple&style=for-the-badge">
</a>
</p>


# Neotest .NET

Neotest adapter for dotnet tests
Expand All @@ -24,6 +28,7 @@ neotest-dotnet requires makes a number of assumptions about your environment:
2. The user is running tests using one of the supported test runners / frameworks (see support grid)
3. (For Debugging) `netcoredbg` is installed and `nvim-dap` plugin has been configured for `netcoredbg` (see debug config for more details)
4. Requires [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) and the parser for C#.
5. Requires `neovim v0.10.0` or later

# Installation

Expand Down Expand Up @@ -90,6 +95,19 @@ require("neotest").setup({
})
```

## Using `.runsettings` files

The plugin provides commands to select and clear the runsettings files (if any are available in the Neovim working director tree).

To select the runsettings file in a Neovim session run:
`:NeotestSelectRunsettingsFile`

- This will apply the runsettings to all tests run via the neotest-adapter

To clear the runsettings file in the same session run:
`:NeotestClearRunsettings`


## Additional `dotnet test` arguments

As well as the `dotnet_additional_args` option in the adapter setup above, you may also provide additional CLI arguments as a table to each `neotest` command.
Expand Down
29 changes: 20 additions & 9 deletions lua/neotest-dotnet/framework-discovery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,22 @@ M.specflow_test_attributes = {
"NUnit.Framework.TestAttribute",
}

M.all_test_attributes = vim.tbl_flatten({
M.xunit_test_attributes,
M.nunit_test_attributes,
M.mstest_test_attributes,
M.specflow_test_attributes,
})
M.all_test_attributes = vim.fn.has("nvim-0.11") == 1
and vim
.iter({
M.xunit_test_attributes,
M.nunit_test_attributes,
M.mstest_test_attributes,
M.specflow_test_attributes,
})
:flatten()
:totable()
or vim.tbl_flatten({
M.xunit_test_attributes,
M.nunit_test_attributes,
M.mstest_test_attributes,
M.specflow_test_attributes,
})

--- Gets a list of the standard and customized test attributes for xUnit, for use in a tree-sitter predicates
---@param custom_attribute_args table The user configured mapping of the custom test attributes
Expand All @@ -54,8 +64,9 @@ function M.attribute_match_list(custom_attribute_args, framework)
end

if custom_attribute_args and custom_attribute_args[framework] then
attribute_match_list =
vim.tbl_flatten({ attribute_match_list, custom_attribute_args[framework] })
attribute_match_list = vim.fn.has("nvim-0.11") == 1
and vim.iter({ attribute_match_list, custom_attribute_args[framework] }):flatten():totable()
or vim.tbl_flatten({ attribute_match_list, custom_attribute_args[framework] })
end

return M.join_test_attributes(attribute_match_list)
Expand Down Expand Up @@ -101,7 +112,7 @@ function M.get_test_framework_utils_from_source(source, custom_attribute_args)
local parsed_query = vim.fn.has("nvim-0.9.0") == 1
and vim.treesitter.query.parse("c_sharp", framework_query)
or vim.treesitter.parse_query("c_sharp", framework_query)
for _, captures in parsed_query:iter_matches(root, source) do
for _, captures, _ in parsed_query:iter_matches(root, source, nil, nil, { all = false }) do
local test_attribute = vim.fn.has("nvim-0.9.0") == 1
and vim.treesitter.get_node_text(captures[1], source)
or vim.treesitter.query.get_node_text(captures[1], source)
Expand Down
43 changes: 43 additions & 0 deletions lua/neotest-dotnet/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,49 @@ setmetatable(DotnetNeotestAdapter, {
if type(opts.discovery_root) == "string" then
discovery_root = opts.discovery_root
end

local function find_runsettings_files()
local files = {}
for _, runsettingsFile in
ipairs(vim.fn.glob(vim.fn.getcwd() .. "**/*.runsettings", false, true))
do
table.insert(files, runsettingsFile)
end

for _, runsettingsFile in
ipairs(vim.fn.glob(vim.fn.getcwd() .. "**/.runsettings", false, true))
do
table.insert(files, runsettingsFile)
end

return files
end

local function select_runsettings_file()
local files = find_runsettings_files()
if #files == 0 then
print("No .runsettings files found")
vim.g.neotest_dotnet_runsettings_path = nil
return
end

vim.ui.select(files, {
prompt = "Select runsettings file:",
format_item = function(item)
return vim.fn.fnamemodify(item, ":p:.")
end,
}, function(choice)
if choice then
vim.g.neotest_dotnet_runsettings_path = choice
print("Selected runsettings file: " .. choice)
end
end)
end

vim.api.nvim_create_user_command("NeotestSelectRunsettingsFile", select_runsettings_file, {})
vim.api.nvim_create_user_command("NeotestClearRunsettings", function()
vim.g.neotest_dotnet_runsettings_path = nil
end, {})
return DotnetNeotestAdapter
end,
})
Expand Down
5 changes: 5 additions & 0 deletions lua/neotest-dotnet/utils/build-spec-utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ function BuildSpecUtils.create_single_spec(position, proj_root, filter_arg, dotn
end
end

if vim.g.neotest_dotnet_runsettings_path then
table.insert(command, "--settings")
table.insert(command, vim.g.neotest_dotnet_runsettings_path)
end

local command_string = table.concat(command, " ")

logger.debug("neotest-dotnet: Running tests using command: " .. command_string)
Expand Down

0 comments on commit 69450e5

Please sign in to comment.