-
Notifications
You must be signed in to change notification settings - Fork 40
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
Implement SkipIf command to skip tests if a condition is met #201
base: master
Are you sure you want to change the base?
Conversation
By checking that there is no more than 1 line in case.skipif and that it is not empty, we know there is only a single line in case.skipif.
Codecov Report
@@ Coverage Diff @@
## master #201 +/- ##
==========================================
- Coverage 86.26% 84.66% -1.61%
==========================================
Files 12 12
Lines 830 854 +24
==========================================
+ Hits 716 723 +7
- Misses 114 131 +17
Continue to review full report at Codecov.
|
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.
Great!
LGTM already.
I've thought about being able to skip a test from within the execute block also / instead, which could be done via a Skip …
command, which itself could be inside some conditional then.
This would e.g. allow for having some basic test, and only extended ones later in the same block.
Internally this could throw a VaderSkipped exception.
Glad to hear it 😄
Interesting idea. The only downside I could think of is that you would still have to run However, that leads me to suggest another approach: The
Would this then report the skip via exceptions in the quickfix window? I personally think reporting the skip only in the vader-result window makes more sense since the skip is not an error per se. Alternatively, the exception could be caught and reported as a warning in the quickfix window instead. Let me know what is more vader-ish. |
This makes sure that a Given block is available to test cases that rely on the same Given block but follow a SkipIf block. Add initial tests.
This sounds like a great feature. I found this PR when looking for a way to skip tests if the tested version of vim is missing required features. It's not clear to me from the examples whether SkipIf applies only to a following block or to the entire vader script. It might be good to require SkipIf to be the first block in the script and it always applies to the whole file -- that would be clearer. Then you could add a Skip command for more fine-grained control |
@idbrii I agree :) it would be very useful.
It currently applies only to a single following
So if I understand you correctly, the I still need some input on these directions from @blueyed. |
But if I delete a given block is deleted, that doesn't skip the test does it? Why would skipping a given block skip a test? |
If you delete a
I think I did not elaborate my last post enough. The
I hope it is more clear what I mean :) |
I think if SkipIf was instead called Require, it would make sense to me. Require ... Given ... Do/Execute ... Then The flow makes more sense. Is making Require/SkipIf like an Execute simpler in implementation? Require:
if !has('patch-8.2.0077')
throw "VaderSkipped: not supported"
endif |
Sure, sounds good. Makes it more distinguishable from the
I believe so. I think the main point here is that it would plug into the existing code that Personally, I would prefer using some kind of Thanks for your input @idbrii! I should have some time tomorrow and next week to start implementing some of this stuff :) |
* Both blocks work like Execute but only for vimscript. * The Require block skips the entire test file is some condition is met. * The SkipIf block skips a single test and must follow its Given block. * A special VaderSkip command is available in both blocks to perform the skip. Internally, a VaderSkipped exception is thrown to signal skips.
I've gotten around to implementing some of the stuff discussed so far.
Require report example:
I have run a few tests but more is needed, and the parser needs some more work. Feedback is welcome. |
@blueyed Any update on this pull request? (apologies for mentioning you if you are not the maintainer. I could not figure out who to bump). |
The previous work had some problems: * it was working for nvim but not at all for vim. * it did not provide any loop-breaking checks before launching doautocmd * it was setting `filetype` from within the syntax file instead of the ftdetect file. This reworks the code to fix most of the above issues. The changes are almost verbatim what Time Pope wrote for the eruby syntax and ftplugin files in vim/nvim. With the changes, vim now is able to correctly identify the subtype based on the file name's extension prior to .epp. This covers most of the basic cases. However, I was not able to find a good way to solve finding the filetype based on parsing file contents and the paths leading to the file. We don't want to reimplement the whole of builtin file detection, which is why @shadowwa was trying to reuse the autocommands already determined. Until we find a way to fix the above issue, we at least now have most of the filetype detection working, which is better than nothing. NOTE: I'm intentionally keeping the tests that are failing for vim in this commit. This way ppl who will investigate this project in the future will be able to see that the tests actually pass on nvim, but not on vim. The next commit will comment out the failing tests though, since vader.vim still doesn't have a SkipIf instruction. See: junegunn/vader.vim#201
Hello! for what it's worth I've just tested out this PR and it seem to work as expected. I've just tried using the changes, I unfortunately can't be too assertive about code style and other details about the code itself. On thing though: the PR defines a hilight region named Otherwise this PR would need to add some details about the new blocks in the README file. It would be especially interesting to document the non-trivial bits of what they do and how to use them. Like the fact that Cheers! and thanks for this PR! |
Thanks for the comments. I'm not using vader.vim anymore and the project appears to be dead so I'm not intending to continue working on this PR. I unfortunately don't remember much of this work since I did it ~5 years ago.
I honestly don't remember what purpose this region served but there are raw and non-raw counterparts for some of the other regions already defined in the syntax file so that might give you a clue. I recall opening this PR mostly as a proof-of-concept to see if it would gain acceptance before writing a bunch of documentation/tests in case it would be scraped which would explain the incomplete state of the PR. You're more than welcome to continue developing it though 🙂 |
in the readme I found out that we can add "TODO:" of "FIXME:" in the description of a Do or Execute block to mark the test as pending. The readme erroneously mentions only "TODO" and "FIXME" though... it's not working without the ":". With this we can include the test result in CI but have it not affect the exit code. It's not a perfect solution though: we could actually have those two tests affect the test results for nvim. That conditional skip though is not implemented. That's what junegunn/vader.vim#201 exists for. Still, it's better this way than just not running the tests at all.
As per #178, this PR implements a
SkipIf
command to skip a test if a condition is met. I have purposefully left out changes to vader's documentation and tests until the implementation has been discussed.The command has been tested with one of my own plugins under neovim v0.3.8 and vim v8.0 on Mac OSX 10.14.6. Internally, if a test is skipped, we continue with the next case instead of throwing an exception since continuing seemed to fit better with the existing code. This is my first PR for vader.vim so bear with me if the implementation is not spot on.
The command is used as follows.
Currently, a single line for the condition (e.g. a function call) must be used in order to avoid a
E488: Trailing characters
error when callingeval
on the condition. The output produced is as follows. Notice that pending is 1 since a single test is skipped.Screenshots with the seoul256.vim colorscheme:
Things left to do:
eval