Skip to content

fix: last test line index#905

Merged
codeinabox merged 1 commit into
vim-test:masterfrom
mark2185:fix-last-test-line-index
May 7, 2026
Merged

fix: last test line index#905
codeinabox merged 1 commit into
vim-test:masterfrom
mark2185:fix-last-test-line-index

Conversation

@mark2185
Copy link
Copy Markdown
Contributor

@mark2185 mark2185 commented May 6, 2026

Make sure these boxes are checked before submitting your pull request:

  • Add fixtures and spec when implementing or updating a test runner
  • Update the README accordingly
  • Update the Vim documentation in doc/test.txt

Without the rewrite of the for loop there was an off-by-two error when searching downwards.

Running just the tests without the fix in place:

-------- Testing a Vim plugin
spec/zig_spec.vim .. 1/?
not ok 5 - Zig update g:test#last_position with exact line of the test
# Expected g:test#last_position['line'] == 4 at line 4
#       Actual value: 6
#     Expected value: 4
spec/zig_spec.vim .. Failed 1/5 subtests

Test Summary Report
-------------------
spec/zig_spec.vim (Wstat: 0 Tests: 5 Failed: 1)
  Failed test:  5
Files=1, Tests=5,  1 wallclock secs ( 0.01 usr  0.00 sys +  0.05 cusr  0.04 csys =  0.10 CPU)
Result: FAIL

The last_position['line'] is used in test#visit to jump to the place where the test was invoked from, but I think it makes more sense that TestVisit actually visits the test it ran.

In case the user ran TestFile, it won't update the last_position['line'].

Note: the PR contains the PR #903 because it tests its new functionality (searching downwards) so that one should get merged first. Rebased!

Note: TestVisit for test runners other than zig will still exhibit the current behavior.

@mark2185 mark2185 force-pushed the fix-last-test-line-index branch from 03db632 to 59713f5 Compare May 6, 2026 13:45
@mark2185
Copy link
Copy Markdown
Contributor Author

mark2185 commented May 6, 2026

@codeinabox I also have a patch that will enable the test runner to run tests that don't have a string literal as a name, but an identifier (test addOne { ... that's already in the test file), should I open up a new PR for that or just chuck it in here as a separate commit?

It's just an additional regex pattern and a spec update.

@codeinabox codeinabox changed the title Fix last test line index fix: last test line index May 7, 2026
Copy link
Copy Markdown
Collaborator

@codeinabox codeinabox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@codeinabox codeinabox merged commit b7ef5aa into vim-test:master May 7, 2026
5 checks passed
@mark2185 mark2185 deleted the fix-last-test-line-index branch May 7, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants