Repository navigation
Add test support crate for plugin developers - #12259
Merged
Merged
Conversation
devyn
marked this pull request as ready for review
March 23, 2024 07:49
Contributor
Author
|
I think this is ready to go! @ayax79 see if you're happy with this. The basic idea for testing examples is: #[test]
fn test_into_u32_examples() -> Result<(), ShellError> {
// you can also pass them directly with .test_examples()
PluginTest::new("custom_u32", CustomU32Plugin.into())?.test_command_examples(&IntoU32)
}and yeah, it works with custom values. There's also APIs for just directly evaluating stuff with or without input, and getting the |
Contributor
|
wow, this seems very cool! |
Contributor
|
Look perfect Thanks! |
Contributor
|
Thanks again @devyn! |
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.
Description
Adds a
nu-plugin-test-supportcrate with an interface that supports testing plugins.Unlike in reality, these plugins run in the same process on separate threads. This will allow
testing aspects of the plugin internal state and handling serialized plugin custom values easily.
We still serialize their custom values and all of the engine to plugin logic is still in play, so
from a logical perspective this should still expose any bugs that would have been caused by that.
The only difference is that it doesn't run in a different process, and doesn't try to serialize
everything to the final wire format for stdin/stdout.
TODO still:
User-Facing Changes
Plugin developers get a nice way to test their plugins.
Tests + Formatting
Run the tests with
cargo test -p nu-plugin-test-support -- --show-outputto see some examples of what the failing test output for examples can look like. I used thedifferencecrate (MIT licensed) to make it look nice.toolkit fmttoolkit clippytoolkit testtoolkit test stdlibAfter Submitting