-
Notifications
You must be signed in to change notification settings - Fork 256
feat(tests): Add baseline testing using Plenary's Busted hooks #106
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
Conversation
47a929d
to
10c4d31
Compare
10c4d31
to
831b21e
Compare
-- | ||
-- When/if editing this, be cautious as (for now) other tests might be accessing | ||
-- files from within this array by index | ||
local fs = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a wrapper function for this, such that you can request a file from the tree in a simpler way (that is also more resistant to change in this list)?
Right now you have to:
local fs = utils.setup_test_fs()
local testfile = fs.content[3].abspath
which is obviously not the best thing because as soon as someone messes with the ordering here, all of those references break. One idea might be to give each file a "handle", and access it by the handle, so that a wrapper function can access it like:
local fs = utils.setup_test_ts()
local testfile = fs.get("top_level_file")
which would return a file that suffices the criteria that is being asked for. You could have handles like "empty_dir"
, "nested_file"
and whatnot which might make this a bit better? This turns into a "yo dawg" issue, where you need tests for your tests and so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the fs.get(id)
method is a good idea. When specifying the nodes, there can be an id
property which is optional, and will default to the relative path. makefs
can then create a lookup table where the keys are that id and the values are the content items. I think this is simple enough that we don't need to worry about.
end | ||
|
||
utils.clear_test_state = function() | ||
-- TODO: Clear internal state? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cseickel thoughts on what is being done for cleanup here? It doesn't seem like quite enough as a lot of the internal state is still retained.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be very simple to add a manager._clear_state()
method. This is where the decision to store all application state in a single object really pays off.
Another way to accomplish the same thing is by creating a new tab and closing the old one. Of course that in itself could have bugs which need to be tested. I think creating a manager._clear_state()
is the best way to go.
Thanks so much for this! You're right, we definitely need this now. I'll dig into this soon. |
As far as your state concerns:
I can't think of any issues with just wiping the state. I tried to keep everything as functional as possible with that single state object. Even where events are subscribed, they are based on configuration no state is part of those subscriptions. The only other thing to cleanup is the file watcher subscriptions, but that already has an
So far, the
I think that's enough, and i can always pop over to your fork and see what you have in the works
Don't worry, I got that one! |
-- | ||
-- When/if editing this, be cautious as (for now) other tests might be accessing | ||
-- files from within this array by index | ||
local fs = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the fs.get(id)
method is a good idea. When specifying the nodes, there can be an id
property which is optional, and will default to the relative path. makefs
can then create a lookup table where the keys are that id and the values are the content items. I think this is simple enough that we don't need to worry about.
end | ||
|
||
utils.clear_test_state = function() | ||
-- TODO: Clear internal state? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be very simple to add a manager._clear_state()
method. This is where the decision to store all application state in a single object really pays off.
Another way to accomplish the same thing is by creating a new tab and closing the old one. Of course that in itself could have bugs which need to be tested. I think creating a manager._clear_state()
is the best way to go.
I think this is a good to merge, unless you want to add anything after reading my responses. I can add the state cleanup in another commit. |
Thanks for the feedback! I'm off for the night so whatever you want to add (either here or elsewhere) is up to you, I'll adapt this to any changes you make. Let me change a few things tomorrow (might leave the state clearing to you but the other stuff is simple/useful enough) and rebase my current stuff to ensure the "harness" still works before merging, then I can ping you again for a follow up. Obviously no rush though. Thanks again @cseickel! |
@cseickel I split this out from the work I am doing on other branches as it seems to be in a relatively good state, and it would be beneficial to have sooner rather than later.
As an overview of what is here:
Makefile
so you can just simplymake test
and run them as you please (alsomake format
to runstylua
)neo-tree
are async, so by default if we do something likevim.cmd("NeoTreeFocus")
and then try to verify stuff, the verification is almost always going to fail as it happens too soon.To show what this ends up looking like:
A few things to note:
state.position
metadata is not wiped. It is pretty easy to just wipe that from existence (the entirestate
object) however I'm not entirely sure what else might need to happen along with that. E.g. bad callbacks, leftover autocommands, etc. so wanted to get your opinion first before going to deep on that. It might be best to just expose a method for testing that "resets" all state (rather than wiping it completely) that any new functionality would need to abide by (meaning providing a way to be reset).neo-tree
once in themininit.lua
, we could likely want a way to modify the configuration between different tests. Not sure how much of an effort this is at the moment.This would be the first step towards #77