Skip to content

Commit

Permalink
ci: run doctests for unstable APIs (#4562)
Browse files Browse the repository at this point in the history
It turns out that the CI job for testing `tokio_unstable` features isn't
actually running doctests for `tokio_unstable`, just lib and integration
tests. This is because RustDoc is responsible for running doctests, and
it needs the unstable cfg passed to it separately from `RUSTFLAGS`.

This means that if the examples for unstable APIs are broken, CI won't
catch this, which is not great!

This commit changes the `test-unstable` CI job to pass `--cfg
tokio_unstable` in `RUSTDOCFLAGS` as well as `RUSTFLAGS`. This way,
doctests for unstable APIs should actually run.

I also fixed a typo in one of the runtime metrics doctests that was
causing a compilation error, which was caught as a result of actually
testing the unstable API docs on CI. :)

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
  • Loading branch information
hawkw committed Mar 11, 2022
1 parent dee26c9 commit 61e37c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -174,6 +174,9 @@ jobs:
working-directory: tokio
env:
RUSTFLAGS: --cfg tokio_unstable -Dwarnings
# in order to run doctests for unstable features, we must also pass
# the unstable cfg to RustDoc
RUSTDOCFLAGS: --cfg tokio_unstable

miri:
name: miri
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/runtime/metrics/runtime.rs
Expand Up @@ -465,7 +465,7 @@ cfg_net! {
/// let registered_fds = metrics.io_driver_fd_registered_count();
/// println!("{} fds have been registered with the runtime's I/O driver.", registered_fds);
///
/// let deregistered_fds = metrics.io_fd_deregistered_count();
/// let deregistered_fds = metrics.io_driver_fd_deregistered_count();
///
/// let current_fd_count = registered_fds - deregistered_fds;
/// println!("{} fds are currently registered by the runtime's I/O driver.", current_fd_count);
Expand All @@ -489,7 +489,7 @@ cfg_net! {
/// async fn main() {
/// let metrics = Handle::current().metrics();
///
/// let n = metrics.io_driver_deregisteredd_fd_count();
/// let n = metrics.io_driver_fd_deregistered_count();
/// println!("{} fds have been deregistered by the runtime's I/O driver.", n);
/// }
/// ```
Expand Down

0 comments on commit 61e37c6

Please sign in to comment.