-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
chore: check each feature works properly #1695
Conversation
Oh, this is not good. It needs to keep the existing one for tests-build. EDIT: fixed in 3eebedc |
hmm...
|
Thanks. I haven't reviewed yet. However, I want to quickly point out that |
But I'd like to try |
@taiki-e I wasn't making a comment on your PR yet, just providing context :) I will probably review on monday. |
UPDATE: It is very hard to maintain these tests manually, so I'm writing a tool to make these checks run in one line :) |
👍 Should I merge this then or wait? |
Also, is the plan to get rid of |
It is hard to maintain features list manually, so use cargo-hack's `--each-feature` flag. And cargo-hack provides a workaround for an issue that dev-dependencies leaking into normal build (`--no-dev-deps` flag), so removed own ci tool. Also, compared to running tests on all features, there is not much advantage in running tests on each feature, so only the default features and all features are tested. If the behavior changes depending on the feature, we need to test it as another job in CI.
this is no longer necessary
It seems rustfmt does not properly format the module in the macro.
I wrote https://github.com/taiki-e/cargo-hack to improve feature flag testing.
By using these two features, you can easily test the feature flag gate:
output:("info: running
This will remove the need to manually list feature flags and tests-build should no longer be needed. |
This reverts commit 519fc6f.
Many features of current cargo-hack are not available on windows. Refs: taiki-e/cargo-hack#3
examples: [] | ||
|
||
# Test compilation failure | ||
# Disable pending: https://github.com/tokio-rs/tokio/pull/1695#issuecomment-547045383 |
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.
Removed :)
displayName: ${{ crate }} - cargo hack check --each-feature | ||
workingDirectory: $(Build.SourcesDirectory)/${{ crate }} | ||
# FIXME(taiki-e): many features of current cargo-hack are not available on windows: https://github.com/taiki-e/cargo-hack/issues/3 | ||
condition: not(eq(variables['Agent.OS'], 'Windows_NT')) |
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.
Unfortunately, many features of current cargo-hack are not available on windows. (taiki-e/cargo-hack#3)
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.
However, it seems many features are not directly related to OS-specific dependencies (7aee1f8), so for now, I think this is almost all right.
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 tried to fix this in taiki-e/cargo-hack#6, but I couldn't fix it completely.
BTW, another benefit is that CI time is significantly reduced. (see also 6bee4d8)
|
@carllerche Updated PR to use cargo-hack. Could you review it again? |
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. We can try it and see how it goes.
I will probably bring back tests-build
at some point so we can check that types exist or don't exist w/ various feature flags.
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 good to me.
IMO, the CI build is quite complex and it would be good to have some more documentation of what it's actually doing. I don't think that's a blocker, though.
@@ -20,6 +20,11 @@ jobs: | |||
# rust_version: stable | |||
rust_version: ${{ parameters.rust }} | |||
|
|||
- script: cargo install cargo-hack |
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 is nitpicky, but it might be helpful to have a comment here explaining what we're using cargo-hack
for and why?
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 wrote descriptions for 'check' scripts, but if necessary, I'd happy to add a description to the 'install' script.
tokio/ci/azure-test-stable.yml
Lines 47 to 50 in 02f7264
# Check each specified feature works properly | |
# * --each-feature - run for each feature which includes --no-default-features and default features of package | |
# * --no-dev-deps - build without dev-dependencies to avoid https://github.com/rust-lang/cargo/issues/4866 | |
- script: cargo hack check --each-feature --no-dev-deps |
tokio/ci/azure-test-stable.yml
Lines 78 to 81 in 02f7264
# Check each specified feature works properly | |
# * --each-feature - run for each feature which includes --no-default-features and default features of package | |
# * --no-dev-deps - build without dev-dependencies to avoid https://github.com/rust-lang/cargo/issues/4866 | |
- script: cargo hack check --each-feature --no-dev-deps |
@carllerche @hawkw Thanks for the review! |
The current tests for each feature gate do not work properly because the default feature is enabled by dev-dependencies.
The cause of this is rust-lang/cargo#4866, but it seems difficult to fix on the cargo side.
So remove all dev-dependencies in CI to avoid this issue. This is basically the same as rust-lang/futures-rs#1456 (comment).EDIT2 see #1695 (comment)Also, this change test to run only once with all-features instead of running tests for each feature.EDIT: see #1695 (comment)Closes #1693
Refs:
no_std
build rust-lang/futures-rs#1456