-
Notifications
You must be signed in to change notification settings - Fork 742
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: run tracing-subscriber's tests under --no-default-features
#1537
chore: run tracing-subscriber's tests under --no-default-features
#1537
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.
LGTM!
In the long run, we may want to do this for other crates that have a large number of feature flags, as well. However, I think tracing-subscriber
, tracing-core
, and tracing
are the main crates that expose a significant amount of flags...
# this skips running doctests under the `--no-default-features` flag, | ||
# as rustdoc isn't aware of cargo's feature flags. | ||
- name: "Test tracing-subscriber with all features disabled" | ||
run: (cd tracing-subscriber && cargo test --lib --tests --no-default-features) |
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.
note: i believe that if we switched the workspace to use resolver = "2"
, we wouldn't have to cd
into each crate's directory. but, this only works on Rust 1.51+, so we would have to wait until our MSRV is 1.51 (e.g., we can't make that change today).
it might be worth leaving a TODO comment for that, though...
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.
oh, another thought. while we're changing this, we may want to change this to use the github actions working-directory
key, rather than (cd tracing-subscriber && ...)
. this is what the cargo hack
checks already do:
tracing/.github/workflows/CI.yml
Line 72 in 005b97a
working-directory: ${{ matrix.subcrate }} |
run: (cd tracing-subscriber && cargo test --lib --tests --no-default-features) | |
run: cargo test --lib --tests --no-default-features | |
working-directory: tracing-subscriber |
We may want to change the other runs in this CI job as well. However, we can also do this in a separate branch.
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.
Added a todo assigned to myself!
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.
actually...while looking at the CI config, I noticed we have a separate job for tracing-subscriber
feature combinations, which does include no-default-features
. However, it only runs cargo check
:
tracing/.github/workflows/CI.yml
Lines 96 to 119 in 005b97a
cargo-check-subscriber: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
featureset: | |
- "" | |
- fmt | |
- fmt ansi | |
- fmt json | |
- fmt json ansi | |
- fmt registry | |
- fmt env-filter | |
- registry | |
- env-filter | |
steps: | |
- uses: actions/checkout@main | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
- name: cargo check | |
working-directory: tracing-subscriber | |
run: cargo check --no-default-features --features "${{ matrix.featureset }}" |
perhaps what we really should do, rather than adding a new run to the tracing
features run, is change that job to use cargo test
rather than cargo check
?
…1537) ## Motivation When reviewing #1523, I suggested that the examples use `fmt::Layer` directly to allow readers to copy-and-paste examples into their own code. However, @hawkw pointed out that rustdoc doesn't receive feature flags from Cargo, which means that running tracing-subscriber's tests under `--no-default-features` would fail. ## Solution It turned out that that we're only running `cargo check --no-default-features` for tracing-subscriber. Running `cargo test --no-default-features` resulted in compilation failures, but it seems like nobody noticed. Building on #1532, this branch argues that running tracing-subscriber's tests under `cargo test --lib --tests --no-default-features` is _probably_ fine if we're able to skip the doctests (which are _not_ aware of Cargo's feature flags).
…1537) ## Motivation When reviewing #1523, I suggested that the examples use `fmt::Layer` directly to allow readers to copy-and-paste examples into their own code. However, @hawkw pointed out that rustdoc doesn't receive feature flags from Cargo, which means that running tracing-subscriber's tests under `--no-default-features` would fail. ## Solution It turned out that that we're only running `cargo check --no-default-features` for tracing-subscriber. Running `cargo test --no-default-features` resulted in compilation failures, but it seems like nobody noticed. Building on #1532, this branch argues that running tracing-subscriber's tests under `cargo test --lib --tests --no-default-features` is _probably_ fine if we're able to skip the doctests (which are _not_ aware of Cargo's feature flags).
For posterity: I reverted my changes as suggested in #1537 (review) because that uncovered some feature combinations that, under test, would not compile, and I was not interested in resolving them at the time. |
Motivation
When reviewing #1523, I suggested that the examples use
fmt::Layer
directly to allow readers to copy-and-paste examples into their own code. However, @hawkw pointed out that rustdoc doesn't receive feature flags from Cargo, which means that running tracing-subscriber's tests under--no-default-features
would fail.Solution
It turned out that that we're only running
cargo check --no-default-features
for tracing-subscriber. Runningcargo test --no-default-features
resulted in compilation failures, but it seems like nobody noticed. Building on #1532, this branch argues that running tracing-subscriber's tests undercargo test --lib --tests --no-default-features
is probably fine if we're able to skip the doctests (which are not aware of Cargo's feature flags).