Skip to content

Commit 525c4f6

Browse files
committed
test: sprinkle cfg(feature = "test-utilities")
Most tests do not compile without this feature, so gate the tests themselves behind it. Signed-off-by: Patrick Roy <[email protected]>
1 parent fc7e661 commit 525c4f6

File tree

5 files changed

+21
-0
lines changed

5 files changed

+21
-0
lines changed

benches/main.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
33

4+
#[cfg(feature = "test_utilities")]
45
use criterion::{criterion_group, criterion_main, Criterion};
56

7+
#[cfg(feature = "test_utilities")]
68
use event_manager::utilities::subscribers::{
79
CounterInnerMutSubscriber, CounterSubscriber, CounterSubscriberWithData,
810
};
11+
#[cfg(feature = "test_utilities")]
912
use event_manager::{EventManager, EventSubscriber, MutEventSubscriber, SubscriberOps};
13+
#[cfg(feature = "test_utilities")]
1014
use std::sync::{Arc, Mutex};
1115

1216
// Test the performance of event manager when it manages a single subscriber type.
1317
// The performance is assessed under stress, all added subscribers have active events.
18+
#[cfg(feature = "test_utilities")]
1419
fn run_basic_subscriber(c: &mut Criterion) {
1520
let no_of_subscribers = 200;
1621

@@ -31,6 +36,7 @@ fn run_basic_subscriber(c: &mut Criterion) {
3136

3237
// Test the performance of event manager when the subscribers are wrapped in an Arc<Mutex>.
3338
// The performance is assessed under stress, all added subscribers have active events.
39+
#[cfg(feature = "test_utilities")]
3440
fn run_arc_mutex_subscriber(c: &mut Criterion) {
3541
let no_of_subscribers = 200;
3642

@@ -52,6 +58,7 @@ fn run_arc_mutex_subscriber(c: &mut Criterion) {
5258
// Test the performance of event manager when the subscribers are wrapped in an Arc, and they
5359
// leverage inner mutability to update their internal state.
5460
// The performance is assessed under stress, all added subscribers have active events.
61+
#[cfg(feature = "test_utilities")]
5562
fn run_subscriber_with_inner_mut(c: &mut Criterion) {
5663
let no_of_subscribers = 200;
5764

@@ -75,6 +82,7 @@ fn run_subscriber_with_inner_mut(c: &mut Criterion) {
7582
// (using CounterSubscriberWithData).
7683
// The performance is assessed under stress, all added subscribers have active events, and the
7784
// CounterSubscriberWithData subscribers have multiple active events.
85+
#[cfg(feature = "test_utilities")]
7886
fn run_multiple_subscriber_types(c: &mut Criterion) {
7987
let no_of_subscribers = 100;
8088

@@ -102,6 +110,7 @@ fn run_multiple_subscriber_types(c: &mut Criterion) {
102110

103111
// Test the performance of event manager when it manages a single subscriber type.
104112
// Just a few of the events are active in this test scenario.
113+
#[cfg(feature = "test_utilities")]
105114
fn run_with_few_active_events(c: &mut Criterion) {
106115
let no_of_subscribers = 200;
107116

@@ -124,6 +133,7 @@ fn run_with_few_active_events(c: &mut Criterion) {
124133
});
125134
}
126135

136+
#[cfg(feature = "test_utilities")]
127137
criterion_group! {
128138
name = benches;
129139
config = Criterion::default()
@@ -133,6 +143,10 @@ criterion_group! {
133143
run_multiple_subscriber_types, run_with_few_active_events
134144
}
135145

146+
#[cfg(feature = "test_utilities")]
136147
criterion_main! {
137148
benches
138149
}
150+
151+
#[cfg(not(feature = "test_utilities"))]
152+
fn main() {}

tests/basic_event_manager.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// The application has an `EventManager` and can register multiple subscribers
88
// of type `CounterSubscriber`.
99

10+
#![cfg(feature = "test_utilities")]
11+
1012
use std::ops::Drop;
1113

1214
use event_manager::utilities::subscribers::CounterSubscriber;

tests/endpoint.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
33

44
#![cfg(feature = "remote_endpoint")]
5+
#![cfg(feature = "test_utilities")]
56

67
use std::any::Any;
78
use std::result;

tests/multi_threaded.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
33

4+
#![cfg(feature = "test_utilities")]
5+
46
use std::sync::{Arc, Mutex};
57
use std::thread;
68

tests/regressions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (C) 2020 Alibaba Cloud. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
33

4+
#![cfg(feature = "test_utilities")]
5+
46
use event_manager::utilities::subscribers::CounterSubscriberWithData;
57
use event_manager::{EventManager, SubscriberOps};
68

0 commit comments

Comments
 (0)