-
Notifications
You must be signed in to change notification settings - Fork 8
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
Use cargo test for plugin integration tests #129
Use cargo test for plugin integration tests #129
Conversation
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.
Thanks for trying to separate things where they belong. This has been slightly bothering me for a while, I think your PR is going in the right direction.
Unfortunately it currently doesn't fully work: The dev build via cargo build
fails with a couple of errors. I have stopped looking at the code, so there's not a lot of feedback on that, but I also assume that you have mostly just moved stuff around.
Also it would be desirable that cargo test
only runs the (fast) unit tests, I usually like to run them via cargo watch -x test
or something. With you changes the integration tests also run by default. Do you know of a way to make that optional? Maybe through a bench or something?
Also, and here I'm not sure what's the Rust way, I think I would intuitively run unit tests with a dev build, while the fuzzer needs to run with an optimized (e.g. release) build, otherwise it times out. Just running cargo test
will result in a timed out fuzzer for me.
Maybe, to break old habits, we also need to document to ourselves how we're expecting which tests to be run as it might change with this PR.
daemon/Cargo.toml
Outdated
async-trait = "0.1.79" | ||
nvim-rs = { version = "0.7.0", features = ["use_tokio"] } | ||
pretty_assertions = "1.4.0" | ||
serde_json = "1" |
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.
This seems to have been added above already? (line 43)
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.
Oops yes! What happened here is that I had sorted the dependencies first before splitting them off into source and dev deps, and then had to revert that sorting to make it easier to audit. Will look for other cases of this, although I will probably be refactoring this again anyway to make the separate plugin-fuzz
subcrate mentioned in my other comment.
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.
Maybe the correct semantic way is to actually "Request changes" :) See comment above on the request.
So the way this is addressed is by doing
So what I had actually done first here was to create a separate subcrate for the fuzzer, the way the Setting all of that aside though, one easy way to solve this might be:
|
I think the "habit" of running |
14e9e39
to
f5d4e1d
Compare
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 have a couple of suggestions related to renaming things! :D But overall, I'm also thankful that you're working on this separation of concerns! Not mixing the test code with the Ethersync code is wonderful.
10412d6
to
a269cf1
Compare
a269cf1
to
2ce44f5
Compare
I'm a bit confused, because I can't reproduce the CI failure locally.
I rebased this PR, and added a tiny README that explains how to run the tests! Thanks for working on this! 🎉 I noticed that you even "minified" the Tokio features in both crates, that's pretty neat! (Any idea why the build didn't fail for me locally before afc77f7?) |
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.
if @blinry likes it, i like it! :-P (didn't take a closer look, but don't want to be the blocker)
Fixes #128.
Problem
We currently have a "fuzzer" binary exported in the
ethersync
crate, which is used for testing random input with the nvim plugin. There's nothing really wrong with this, but it means we have to pull several crates into[dependencies]
instead of[dev-dependencies]
, and it's not clear thatactors.rs
is a testing framework instead of somehow part ofethersync
itself. @blinry advised (#127 (comment)) makingbin/fuzzer.rs
into an integration test.Solution
tests/
directory for integration tests that exercise each plugin.actors.rs
intotests/common/mod.rs
to be usable by integration tests.test
submodule ofactors.rs
intotests/vim-plugin.rs
, since#[test]
functions are ignored in integration test sources.src/bin/fuzzer.rs
totests/random-input-nvim.rs
and setharness = false
inCargo.toml
so we can continue to use the samemain()
method.-v
to its command line to get debugging output..github/workflows/general.yml
to run unit vs integration tests instead of callingcargo run
.[dev-dependencies]
.time-macros
,local-ip-address
, andpublic-ip
.tokio
.clap
into an optional dependency, and enable it under a new"executable-deps"
feature (which defaults to on)..github/workflows/general.yml
to use--no-default-features
to avoid pulling inclap
.Result
cargo test
!cargo test --lib
runs unit tests, andcargo test --test '*'
runs integration tests.ethersync
binary is slightly smaller: