File tree Expand file tree Collapse file tree 5 files changed +9
-19
lines changed Expand file tree Collapse file tree 5 files changed +9
-19
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ use crates_io_test_db::TestDatabase;
3
3
4
4
#[ test]
5
5
fn dump_db_and_reimport_dump ( ) {
6
- let _guard = crates_io:: util:: tracing:: init_for_test ( ) ;
6
+ crates_io:: util:: tracing:: init_for_test ( ) ;
7
7
8
8
let db_one = TestDatabase :: new ( ) ;
9
9
Original file line number Diff line number Diff line change @@ -23,12 +23,8 @@ use oauth2::{ClientId, ClientSecret};
23
23
use std:: collections:: HashSet ;
24
24
use std:: { rc:: Rc , sync:: Arc , time:: Duration } ;
25
25
use tokio:: runtime:: Runtime ;
26
- use tracing:: subscriber:: DefaultGuard ;
27
26
28
27
struct TestAppInner {
29
- #[ allow( dead_code) ]
30
- tracing_guard : DefaultGuard ,
31
-
32
28
pub runtime : Runtime ,
33
29
34
30
app : Arc < App > ,
@@ -81,10 +77,9 @@ pub struct TestApp(Rc<TestAppInner>);
81
77
impl TestApp {
82
78
/// Initialize an application with an `Uploader` that panics
83
79
pub fn init ( ) -> TestAppBuilder {
84
- let tracing_guard = crates_io:: util:: tracing:: init_for_test ( ) ;
80
+ crates_io:: util:: tracing:: init_for_test ( ) ;
85
81
86
82
TestAppBuilder {
87
- tracing_guard,
88
83
config : simple_config ( ) ,
89
84
index : None ,
90
85
build_job_runner : false ,
@@ -210,7 +205,6 @@ impl TestApp {
210
205
}
211
206
212
207
pub struct TestAppBuilder {
213
- tracing_guard : DefaultGuard ,
214
208
config : config:: Server ,
215
209
index : Option < UpstreamIndex > ,
216
210
build_job_runner : bool ,
@@ -297,7 +291,6 @@ impl TestAppBuilder {
297
291
} ;
298
292
299
293
let test_app_inner = TestAppInner {
300
- tracing_guard : self . tracing_guard ,
301
294
runtime,
302
295
app,
303
296
test_database,
Original file line number Diff line number Diff line change 1
1
use sentry:: integrations:: tracing:: EventFilter ;
2
- use tracing:: subscriber:: DefaultGuard ;
3
2
use tracing:: Level ;
4
3
use tracing:: Metadata ;
5
4
use tracing_subscriber:: filter:: LevelFilter ;
@@ -47,17 +46,15 @@ pub fn event_filter(metadata: &Metadata<'_>) -> EventFilter {
47
46
}
48
47
49
48
/// Initializes the `tracing` logging framework for usage in tests.
50
- pub fn init_for_test ( ) -> DefaultGuard {
49
+ pub fn init_for_test ( ) {
51
50
let env_filter = EnvFilter :: builder ( )
52
51
. with_default_directive ( LevelFilter :: INFO . into ( ) )
53
52
. from_env_lossy ( ) ;
54
53
55
- let subscriber = tracing_subscriber:: fmt ( )
54
+ let _ = tracing_subscriber:: fmt ( )
56
55
. compact ( )
57
56
. with_env_filter ( env_filter)
58
57
. without_time ( )
59
58
. with_test_writer ( )
60
- . finish ( ) ;
61
-
62
- tracing:: subscriber:: set_default ( subscriber)
59
+ . try_init ( ) ;
63
60
}
Original file line number Diff line number Diff line change @@ -395,7 +395,7 @@ mod tests {
395
395
396
396
#[ tokio:: test]
397
397
async fn test_process_cdn_log ( ) {
398
- let _guard = crate :: util:: tracing:: init_for_test ( ) ;
398
+ crate :: util:: tracing:: init_for_test ( ) ;
399
399
400
400
let test_database = TestDatabase :: new ( ) ;
401
401
let db_pool = build_connection_pool ( test_database. url ( ) ) ;
Original file line number Diff line number Diff line change @@ -233,7 +233,7 @@ mod tests {
233
233
234
234
#[ tokio:: test]
235
235
async fn test_process_cdn_log_queue ( ) {
236
- let _guard = crate :: util:: tracing:: init_for_test ( ) ;
236
+ crate :: util:: tracing:: init_for_test ( ) ;
237
237
238
238
let mut queue = Box :: new ( MockSqsQueue :: new ( ) ) ;
239
239
queue
@@ -263,7 +263,7 @@ mod tests {
263
263
264
264
#[ tokio:: test]
265
265
async fn test_process_cdn_log_queue_multi_page ( ) {
266
- let _guard = crate :: util:: tracing:: init_for_test ( ) ;
266
+ crate :: util:: tracing:: init_for_test ( ) ;
267
267
268
268
let mut queue = Box :: new ( MockSqsQueue :: new ( ) ) ;
269
269
queue
@@ -323,7 +323,7 @@ mod tests {
323
323
324
324
#[ tokio:: test]
325
325
async fn test_process_cdn_log_queue_parse_error ( ) {
326
- let _guard = crate :: util:: tracing:: init_for_test ( ) ;
326
+ crate :: util:: tracing:: init_for_test ( ) ;
327
327
328
328
let mut queue = Box :: new ( MockSqsQueue :: new ( ) ) ;
329
329
queue
You can’t perform that action at this time.
0 commit comments