-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Replace test-invocation-variants.sh
with cargo test
#215
Conversation
test-invocation-variants.sh
tests with proper cargo test
teststest-invocation-variants.sh
with cargo test
081dd3f
to
446faec
Compare
446faec
to
90218ee
Compare
This makes `scripts/run-ci-locally.sh` run in 10s instead of 12s for me. It also significantly simplifies the testing setup.
90218ee
to
7fdb404
Compare
I think the problem we are seeing is rust-lang/rustup#988 We might need to handle An adventure for some other day... |
The use of `&` is because pedantic clippy insists on it.
let mut cmd = Command::from_std(std::process::Command::new("cargo")); | ||
if let Some(toolchain) = toolchain { | ||
cmd.arg(format!("+{}", toolchain)); | ||
} | ||
cmd.arg("public-api"); |
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.
might want to do the same thing as here:
cargo-public-api/cargo-public-api/src/toolchain.rs
Lines 10 to 12 in e5324e4
let mut cmd = std::process::Command::new("rustup"); | |
cmd.args(["run", toolchain, "cargo"]); | |
cmd |
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.
Hmm yes that might work, but then the test would not do what regular users do, which IMHO is quite important.
After thinking some more about how to approach this short term, I think requiring toolchains to be pre-installed before tests run is reasonable, and provide a helper script to do so. I'd really like to get this PR merge sooner rather than later, because otherwise the risk of conflicts is high, and I see it as a significant improvement.
If I just can get this to work in Windows now...
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.
My bad, I should have made myself clear.
The code works around rust-lang/rustup#3036, which is this exact issue (however the error message seems to have changed a bit)
error: no such subcommand: `+beta`
Cargo does not handle `+toolchain` directives.
Did you mean to invoke `cargo` through `rustup` instead?
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 a ton for clarifying. I had completely forgotten about that bug. You saved me a lot of debugging time.
I've pushed a fix now, and CI is green.
I can think of many follow-up improvements to this PR, but let's get this merged before we improve on it further.
One idea:
Why don't we put the helper to install toolchains in e.g. rustdoc-json
crate, and then install the necessary toolchain automatically for users (if it is missing) during regular cargo public-api
use?
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 would not expect rustdoc-json
to have rustup stuff in it. I'm definitely myself against installing the toolchain automatically via a rustup toolchain install
but I see the value 👍🏼
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.
Interesting viewpoint! Let's break it down to a specific example. Consider a user that has stable
installed but not nightly
. Then that user does cargo install cargo-public-api
and then cargo public-api
.
In this case, I bet that say 95% of users want us to do the work to install nightly
for them. Otherwise the tool that they just downloaded is useless!
The 5% that do NOT want us to install nightly
for them can just Ctrl-C and stop the process.
This is a classic interaction design rule actually. Don't let the 5% ruin the experience for the other 95% :)
I am of course happy to keep discussing this. There might very well be some aspect here I am not thinking about. Meanwhile, I have created a new rustup-toolchain
crate: https://crates.io/crates/rustup-toolchain, which we'll need it regardless of if we install nightly
by default or allow users to opt-in
. I'll wait with creating a PR for that though until we have landed this PR.
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.
good point, I guess I'm that 5% :D
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 did a quick experiment, but all tests started failing after uninstalling nightly
toolchain, so I don't see me pursuing auto-install in the near future
For the record, prototype code at main...auto-install-toolchain
I mean, probably quite easy to make it work, but I don't consider this urgent or crucial, so I'll put it on hold for now
Which will install toolchains needed for tests. Long-term it will be nice to get rid of this, but since this is a one-time thing, I think we can live with it. If a dev runs `cargo test` with missing toolchains, the dev will see this error: thread 'warn_when_using_beta' panicked at ' You must run ./scripts/install-toolchains-for-tests.sh before running tests. Or simply run ./scripts/run-ci-locally.sh to both install toolchains and run tests in one command. ', cargo-public-api/tests/../../test-utils/src/lib.rs:70:5
9302261
to
e1a3b4b
Compare
Hmm interesting, we get the same error now. So probably we don't need Maybe time for me to buy a Windows license so I can debug this... |
8171531
to
7054ed9
Compare
This reverts commit e1a3b4b. Keep some of the changes to the README though.
Since a single test takes a very long time if it needs to install a toolchain, I want there to be an indication of what is going on and why the test is so slow.
This makes
./scripts/run-ci-locally.sh
run in ~10s instead of ~12s for me.It also significantly simplifies the testing infrastructure.