Skip to content
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

subscriber: add feature flags to tests #1532

Merged
merged 1 commit into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tracing-subscriber/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,6 @@ impl Identity {

#[cfg(test)]
pub(crate) mod tests {
use std::sync::{Arc, Mutex};

use super::*;

Expand Down Expand Up @@ -1419,7 +1418,9 @@ pub(crate) mod tests {
}

#[test]
#[cfg(feature = "registry")]
fn context_event_span() {
use std::sync::{Arc, Mutex};
let last_event_span = Arc::new(Mutex::new(None));

struct RecordingLayer {
Expand Down
2 changes: 1 addition & 1 deletion tracing-subscriber/src/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ where
}
}

#[cfg(test)]
#[cfg(all(test, feature = "registry"))]
mod tests {
use crate::{
layer::{Context, Layer},
Expand Down
1 change: 1 addition & 0 deletions tracing-subscriber/tests/duplicate_spans.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(all(feature = "env-filter", feature = "fmt"))]
mod support;
use tracing::{self, subscriber::with_default, Span};
use tracing_subscriber::{filter::EnvFilter, FmtSubscriber};
Expand Down
1 change: 1 addition & 0 deletions tracing-subscriber/tests/field_filter.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "env-filter")]
mod support;
use self::support::*;
use tracing::{self, subscriber::with_default, Level};
Expand Down
2 changes: 2 additions & 0 deletions tracing-subscriber/tests/filter.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "env-filter")]

mod support;
use self::support::*;
use tracing::{self, subscriber::with_default, Level};
Expand Down
1 change: 1 addition & 0 deletions tracing-subscriber/tests/filter_log.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(all(feature = "env-filter", feature = "tracing-log"))]
mod support;
use self::support::*;
use tracing::{self, Level};
Expand Down
1 change: 1 addition & 0 deletions tracing-subscriber/tests/fmt_max_level_hint.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "fmt")]
use tracing_subscriber::filter::LevelFilter;

#[test]
Expand Down
1 change: 1 addition & 0 deletions tracing-subscriber/tests/registry_max_level_hint.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(all(feature = "registry", feature = "fmt"))]
use tracing_subscriber::{filter::LevelFilter, prelude::*};

#[test]
Expand Down
1 change: 1 addition & 0 deletions tracing-subscriber/tests/registry_with_subscriber.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "registry")]
use tracing_futures::{Instrument, WithSubscriber};
use tracing_subscriber::prelude::*;

Expand Down
1 change: 1 addition & 0 deletions tracing-subscriber/tests/reload.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "reload")]
use std::sync::atomic::{AtomicUsize, Ordering};
use tracing_core::{
span::{Attributes, Id, Record},
Expand Down
2 changes: 1 addition & 1 deletion tracing-subscriber/tests/same_len_filters.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// These tests include field filters with no targets, so they have to go in a
// separate file.

#![cfg(feature = "env-filter")]
mod support;
use self::support::*;
use tracing::{self, subscriber::with_default, Level};
Expand Down
2 changes: 2 additions & 0 deletions tracing-subscriber/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fn init_ext_works() {
}

#[test]
#[cfg(feature = "fmt")]
fn builders_are_init_ext() {
tracing_subscriber::fmt().set_default();
let _ = tracing_subscriber::fmt()
Expand All @@ -28,6 +29,7 @@ fn builders_are_init_ext() {
}

#[test]
#[cfg(all(feature = "fmt", feature = "env-filter"))]
fn layered_is_init_ext() {
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
Expand Down