Skip to content

Commit

Permalink
chore: run tracing-subscriber's tests under --no-default-features (#…
Browse files Browse the repository at this point in the history
…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).
  • Loading branch information
davidbarsky authored and hawkw committed Sep 4, 2021
1 parent 753370b commit d10d6b2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ jobs:

features-stable:
# Feature flag tests that run on stable Rust.
# TODO(david): once tracing's MSRV goes up to Rust 1.51, we should be able to switch to
# using cargo's V2 feature resolver (https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions)
# and avoid cd'ing into each crate's directory.
needs: check
runs-on: ubuntu-latest
steps:
Expand All @@ -234,6 +237,10 @@ jobs:
run: (cd tracing-core && cargo test --no-default-features)
- name: "Test tracing no-std support"
run: (cd tracing && cargo test --no-default-features)
# 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)

style:
# Check style.
Expand Down

0 comments on commit d10d6b2

Please sign in to comment.