Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declutter infoview tests. #104

Merged
merged 13 commits into from
Jul 27, 2021
Merged

Declutter infoview tests. #104

merged 13 commits into from
Jul 27, 2021

Conversation

rish987
Copy link
Collaborator

@rish987 rish987 commented Jul 24, 2021

Should also make testing infoview-specific stuff much more deliberate and complete!

@codecov
Copy link

codecov bot commented Jul 24, 2021

Codecov Report

Merging #104 (05fcb4d) into main (ba7562e) will increase coverage by 0.28%.
The diff coverage is 98.13%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #104      +/-   ##
==========================================
+ Coverage   92.15%   92.43%   +0.28%     
==========================================
  Files          25       27       +2     
  Lines        1109     1243     +134     
==========================================
+ Hits         1022     1149     +127     
- Misses         87       94       +7     
Impacted Files Coverage Δ
lua/tests/helpers.lua 95.40% <96.21%> (+1.20%) ⬆️
lua/tests/infoview/autoopen_false_spec.lua 100.00% <100.00%> (ø)
lua/tests/infoview/autoopen_spec.lua 100.00% <100.00%> (ø)
lua/tests/infoview/close_all_spec.lua 100.00% <100.00%> (ø)
lua/tests/infoview/run_spec.lua 100.00% <100.00%> (ø)
lua/tests/infoview/toggle_spec.lua 100.00% <100.00%> (ø)
lua/lean/abbreviations.lua 65.92% <0.00%> (-8.15%) ⬇️
lua/tests/abbreviations/snippets_nvim_spec.lua
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ba7562e...05fcb4d. Read the comment docs.

@rish987 rish987 marked this pull request as draft July 25, 2021 01:58
@rish987 rish987 marked this pull request as ready for review July 25, 2021 02:25
lua/lean/infoview.lua Outdated Show resolved Hide resolved
lua/tests/helpers.lua Outdated Show resolved Hide resolved
@@ -116,11 +122,130 @@ local function has_all(_, arguments)
return true
end

local prev_buf_max = -1
Copy link
Owner

Choose a reason for hiding this comment

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

This seems quite fragile to me because it adds global mutable state to all infoview-touching test runs. Would really prefer if we avoided doing that, we're already struggling with #94 showing us we have too much mutable state.

Copy link
Collaborator Author

@rish987 rish987 Jul 26, 2021

Choose a reason for hiding this comment

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

This is something that you'd "opt-in" to on certain tests, and should be backwards compatible with the way we did things before (see e.g. infoview/lsp_spec.lua). ISTM that mutable state is pretty much the only way to get this kind of coverage, and the mutable state before was just littered throughout the tests themselves rather than centralized in a helper (not to mention being hopelessly incomplete).

Did you perhaps mean #93? I'm pretty sure at this point the best way to handle it would be to:

  1. Split up infoview/run_spec.lua.
  2. Add a feature to nvim-lua/plenary.nvim that allows tests to early-abort as soon as an it() fails, so only the first error is shown.

@rish987 rish987 marked this pull request as draft July 25, 2021 13:29
@rish987
Copy link
Collaborator Author

rish987 commented Jul 26, 2021

@Julian Thanks for the nudge. What I had before was actually a pretty bad take, sorry for making you read through it. I pretty much overhauled this in the recent commit, it should hopefully be much easier to follow now! And at this point I think it gives 100% coverage of what I wanted to test.

@rish987
Copy link
Collaborator Author

rish987 commented Jul 26, 2021

Will add more assert messages and split up infoview/run_spec.lua tommorrow!

@rish987 rish987 marked this pull request as ready for review July 26, 2021 03:19
@rish987 rish987 marked this pull request as draft July 26, 2021 03:19
@rish987 rish987 marked this pull request as ready for review July 26, 2021 03:19
@rish987
Copy link
Collaborator Author

rish987 commented Jul 27, 2021

Okay, should be good for a review now! The only last thing I want to do is add a few helpful assertion failure messages, will do soon. Also regarding #93, see aa8b0db, nvim-lua/plenary.nvim#196 and nvim-lua/plenary.nvim#197.

@Julian
Copy link
Owner

Julian commented Jul 27, 2021

Nice! Thanks for more fun upstream work, well done. Yeah sounds good to merge here then to me!

@rish987 rish987 merged commit 7758c29 into Julian:main Jul 27, 2021
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