Repository navigation
fix: stop a file spinning forever when its tests aren't discovered yet - #20
Merged
Merged
Conversation
Running the nearest test before neotest had discovered a file's tests made neotest run the file itself. With no test items, build_spec returned nil, neotest found nothing to split the run into, and the file never got a result, so it stayed marked as running until the whole file was run. build_spec now discovers the file on the spot and runs the test at the cursor, or every test when the file isn't in the current window. It errors when the file has no tests, which neotest reports and clears. results also always reports the position that was run.
…back collect_leaf_items returns a fresh list, the no-tests error lives with the discovery it checks, and results keeps one fallback for the run position instead of two copies of the failed result. The cursor fixture in the spec uses luassert stubs.
Raising from build_spec skipped neotest's runner cleanup, so the file stayed in its running table, and the message arrived wrapped in a stack trace. Now the fallback notifies with a short reason and returns a spec that exits at once, which results marks as skipped. A failed discovery says so instead of reporting no tests, and the current-buffer check compares resolved paths so symlinked projects still pick the test at the cursor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pressing
<leader>tt(neotest.run.run()) before neotest had discovered a file's tests left the file's spinner running forever in the summary. Running the test again didn't clear it. Running the whole file did.Cause
With no test children yet, neotest's nearest position is the file. Our
build_spechad no items for it and returnednil. neotest then breaks the run into tests, finds none, and ends without results. It only clears "running" for positions that get a result, so the file stayed running.Fix
build_specdiscovers an undiscovered file on the spot (the samediscoverTestscall, factored out ofdiscover_positions). It runs the test at the cursor when the file is in the current window, and every test otherwise.resultsalways reports the position that was run.Testing
make test: 200 passing, 0 failures. The four new tests failed before the fix.make lint: cleanrunningwith no result. After, the run resolvedbin/rails test …/donation_test.rb:163for the test under the cursor, passed, and the file stopped running.