Comments (17)
@bmulholland @alxekb could you both check neotest-rspec and raise any issues in the repo? Functionality should be there but suspect there will be some edge cases:
As I mentioned above, creating IDs via Treesitter to match to RSpec is a nuisance and my fix is a tonne of string replacement. Long term, I'd love to be able to conjure up some way of making neotest
+ treesitter
form ids which match RSpec's id key (example: "id": "./spec/neotest_spec.rb[1:2:1]",
).
from neotest.
@bmulholland I started working on an rspec adapter today btw. Treesitter queries are done and I just need to build out the NeotestAdapter.results
function. Will try and sort this weekend.
from neotest.
@hahuang65 the "JSON jumble" should be no more in the latest release and you should delicious color output from RSpec now.
from neotest.
Looks great! 😁 I think this can be closed alright, issues with the adapter can be filed there now
from neotest.
Sounds good! Happy to help with any questions/issues 😁
from neotest.
So you can customise the IDs assigned to the positions to be whatever you want, it's totally arbitrary as long as they're unique. You can do so by passing a position_id
function in the treesitter parsing opts. The default is here https://github.com/nvim-neotest/neotest/blob/master/lua/neotest/lib/treesitter/init.lua#L148. It looks like you can just concatenate with a space instead of "::" and it should be easy to match the results then
from neotest.
It shouldn't, the size of repos which that relates to is massive. I've been testing using the CPython repo which is easily handled with 724 test files, containing nearly 22000 tests. It is possible that on some machines that many files are opened at the same time before they start closing. It's weird that I've not seen anyone else encountering it but definitely still possible.
Actually just spotted that neotest-rspec is using lib.treesitter.parse_positions_from_string
instead of lib.treesitter.parse_positions
. parse_positions
contains a sleep to prevent hogging resources, it could also be preventing the issue seen here, @olimorris could you switch to using that (and remove the line where you read the file contents) and then we can see if that helps
from neotest.
Ooooh good spot.
@zidhuss pushed a fix which may solve your issue.
from neotest.
Basic functionality is now complete. Running lua require("neotest").run.run()
and lua require("neotest").run.run(vim.fn.expand("%"))
works on simple use cases.
One of the most challenging parts of this was understanding the results collection process. To align the id from neotest.Tree
with RSpec's output, I had to do some messy string manipulation based on the full_description
key in the output:
{
"version": "3.11.0",
"examples": [
{
"id": "./spec/neotest_spec.rb[1:1:1]",
"description": "returns 4",
"full_description": "Some maths calculations passing test returns 4",
"status": "passed",
"file_path": "./spec/neotest_spec.rb",
"line_number": 3,
"run_time": 0.000176,
"pending_message": null
}
],
"summary": {
"duration": 0.000548,
"example_count": 1,
"failure_count": 0,
"pending_count": 0,
"errors_outside_of_examples_count": 0
},
"summary_line": "1 example, 0 failures"
}
My example RSpec test is:
# neotest_spec.rb
describe 'Some maths calculations' do
context 'passing test' do
it 'returns 4' do
expect(2 + 2).to eq(4)
end
end
end
@rcarriga would appreciate your input on how to make this better...it's possible I'm misunderstanding how to collect results and there maybe a much cleaner way of doing it. The challenge I will run into with string manipulation is how I deal with tests which have ::
in their namespaces.
from neotest.
@olimorris thank you so much, going to check this.
from neotest.
The simple example that you have in your repo works fine for me.
However it was failing silently in a bigger project. Looking through the neotest logs there were lots of instances of the following error:
ERROR | 2022-06-13T13:43:03Z+0400 | ...te/pack/packer/start/neotest/lua/neotest/client/init.lua:415 | Couldn't find positions in path REDACTED_spec.rb .../pack/packer/start/neotest/lua/neotest/lib/file/init.lua:15: EMFILE: too many open files: REDACTED_spec.rb
Current config:
require("neotest").setup({
adapters = {
require("neotest-python")({
dap = { justMyCode = false },
}),
require("neotest-rspec"),
require("neotest-vim-test")({
ignore_file_types = { "python", "vim", "lua", "ruby" },
}),
},
})
from neotest.
How many tests do you have in your spec folder?
from neotest.
Around 4700 tests in ~400 spec files.
from neotest.
Daym! @rcarriga could this also be related to #13?
from neotest.
I'm now up and running with @olimorris' adapter 🎉
Should I close this out @rcarriga ?
from neotest.
Have you been able to see the messages in the output section? I get a JSON jumble, so I'm assuming I set something up incorrectly?
from neotest.
@hahuang65 Yeah that's a consequence of how the adapter works so far. I filed olimorris/neotest-rspec#9 for you. neotest-rspec is intended to be by the community for the community, so your help in moving it forward (even a little) would be really helpful. Perhaps you could investigate how neotest-pytest does it to see which approach neotest-rspec should consider?
(And @rcarriga -- if you have guidance on how to make the test output human friendly while having convenient ways to parse the test results for programmatic things like gutter signs, that would probably be helpful for other adapters too.)
from neotest.
Related Issues (20)
- [BUG] nested_tests causes test output from stdout/stderr to be printed undesirably
- [BUG] Files containing no tests shouldn't show up in summary
- [BUG] subprocess fails on non-default environments HOT 1
- Passing additional test arguments to runner HOT 1
- Feature Request: Set Notification Levels
- [BUG] Getting error "Future already set" and output_panel is empty for python tests HOT 7
- [Feature Request] Boost.Test supporting HOT 2
- Deprecation warnings on neovim 0.11
- [BUG] Summary opens, but no help HOT 2
- Graciously handling DAP failure on multistep (build then run) languages HOT 1
- [doc] Replace README recommendation of neodev with lazydev
- New Adapter: neotest-ctest - A neotest adapter for C/C++ using CTest as a test runner HOT 1
- [BUG] ImportError while importing test module HOT 3
- [BUG] "No tests found" when opening the summary window rigth before running tests the first time
- [BUG] Java file watcher does not work as the jdtls is marked as an invalid lsp HOT 1
- Lazy load adapters HOT 1
- [Question] Subprocess with `--clean` flag
- [Feature Request] Enable setting custom environment variables for summary runs HOT 2
- [Feature] option to hide the adapter name
- [Documentation] RunSpec stream clarification HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neotest.