@@ -120,9 +120,13 @@ pub(crate) fn parse_spec(spec: &str) -> ParseResult {
120120
121121#[ cfg( test) ]
122122mod tests {
123+ use alloc:: { borrow:: ToOwned , string:: ToString } ;
124+
123125 use crate :: ParseError ;
124126 use log:: LevelFilter ;
125- use snapbox:: { assert_data_eq, str, Data , IntoData } ;
127+ #[ cfg( feature = "std" ) ]
128+ use snapbox:: { assert_data_eq, str} ;
129+ use snapbox:: { Data , IntoData } ;
126130
127131 use super :: { parse_spec, ParseResult } ;
128132
@@ -169,6 +173,7 @@ mod tests {
169173 assert ! ( filter. is_none( ) ) ;
170174
171175 assert_eq ! ( errors. len( ) , 1 ) ;
176+ #[ cfg( feature = "std" ) ]
172177 assert_data_eq ! (
173178 & errors[ 0 ] ,
174179 str ![ "invalid logging spec 'crate1::mod1=warn=info'" ]
@@ -190,6 +195,7 @@ mod tests {
190195 assert ! ( filter. is_none( ) ) ;
191196
192197 assert_eq ! ( errors. len( ) , 1 ) ;
198+ #[ cfg( feature = "std" ) ]
193199 assert_data_eq ! ( & errors[ 0 ] , str ![ "invalid logging spec 'noNumber'" ] ) ;
194200 }
195201
@@ -208,6 +214,7 @@ mod tests {
208214 assert ! ( filter. is_none( ) ) ;
209215
210216 assert_eq ! ( errors. len( ) , 1 ) ;
217+ #[ cfg( feature = "std" ) ]
211218 assert_data_eq ! ( & errors[ 0 ] , str ![ "invalid logging spec 'wrong'" ] ) ;
212219 }
213220
@@ -226,6 +233,7 @@ mod tests {
226233 assert ! ( filter. is_none( ) ) ;
227234
228235 assert_eq ! ( errors. len( ) , 1 ) ;
236+ #[ cfg( feature = "std" ) ]
229237 assert_data_eq ! ( & errors[ 0 ] , str ![ "invalid logging spec 'wrong'" ] ) ;
230238 }
231239
@@ -399,6 +407,7 @@ mod tests {
399407 assert ! ( filter. is_some( ) && filter. unwrap( ) . to_string( ) == "a.c" ) ;
400408
401409 assert_eq ! ( errors. len( ) , 1 ) ;
410+ #[ cfg( feature = "std" ) ]
402411 assert_data_eq ! (
403412 & errors[ 0 ] ,
404413 str ![ "invalid logging spec 'crate1::mod1=error=warn'" ]
@@ -430,6 +439,7 @@ mod tests {
430439 assert ! ( filter. is_none( ) ) ;
431440
432441 assert_eq ! ( errors. len( ) , 1 ) ;
442+ #[ cfg( feature = "std" ) ]
433443 assert_data_eq ! (
434444 & errors[ 0 ] ,
435445 str ![ "invalid logging spec 'debug/abc/a.c' (too many '/'s)" ]
@@ -451,14 +461,17 @@ mod tests {
451461 assert ! ( filter. is_none( ) ) ;
452462
453463 assert_eq ! ( errors. len( ) , 2 ) ;
454- assert_data_eq ! (
455- & errors[ 0 ] ,
456- str ![ "invalid logging spec 'crate1::mod1=warn=info'" ]
457- ) ;
458- assert_data_eq ! (
459- & errors[ 1 ] ,
460- str ![ "invalid logging spec 'crate3=error=error'" ]
461- ) ;
464+ #[ cfg( feature = "std" ) ]
465+ {
466+ assert_data_eq ! (
467+ & errors[ 0 ] ,
468+ str ![ "invalid logging spec 'crate1::mod1=warn=info'" ]
469+ ) ;
470+ assert_data_eq ! (
471+ & errors[ 1 ] ,
472+ str ![ "invalid logging spec 'crate3=error=error'" ]
473+ ) ;
474+ }
462475 }
463476
464477 #[ test]
@@ -476,8 +489,11 @@ mod tests {
476489 assert ! ( filter. is_none( ) ) ;
477490
478491 assert_eq ! ( errors. len( ) , 2 ) ;
479- assert_data_eq ! ( & errors[ 0 ] , str ![ "invalid logging spec 'noNumber'" ] ) ;
480- assert_data_eq ! ( & errors[ 1 ] , str ![ "invalid logging spec 'invalid'" ] ) ;
492+ #[ cfg( feature = "std" ) ]
493+ {
494+ assert_data_eq ! ( & errors[ 0 ] , str ![ "invalid logging spec 'noNumber'" ] ) ;
495+ assert_data_eq ! ( & errors[ 1 ] , str ![ "invalid logging spec 'invalid'" ] ) ;
496+ }
481497 }
482498
483499 #[ test]
@@ -495,18 +511,23 @@ mod tests {
495511 assert ! ( filter. is_none( ) ) ;
496512
497513 assert_eq ! ( errors. len( ) , 2 ) ;
498- assert_data_eq ! (
499- & errors[ 0 ] ,
500- str ![ "invalid logging spec 'crate1::mod1=debug=info'" ]
501- ) ;
502- assert_data_eq ! ( & errors[ 1 ] , str ![ "invalid logging spec 'invalid'" ] ) ;
514+ #[ cfg( feature = "std" ) ]
515+ {
516+ assert_data_eq ! (
517+ & errors[ 0 ] ,
518+ str ![ "invalid logging spec 'crate1::mod1=debug=info'" ]
519+ ) ;
520+ assert_data_eq ! ( & errors[ 1 ] , str ![ "invalid logging spec 'invalid'" ] ) ;
521+ }
503522 }
504523
505524 #[ test]
506525 fn parse_error_message_single_error ( ) {
526+ #[ allow( unused_variables) ]
507527 let error = parse_spec ( "crate1::mod1=debug=info,crate2=debug" )
508528 . ok ( )
509529 . unwrap_err ( ) ;
530+ #[ cfg( feature = "std" ) ]
510531 assert_data_eq ! (
511532 error,
512533 str ![ "error parsing logger filter: invalid logging spec 'crate1::mod1=debug=info'" ]
@@ -515,9 +536,11 @@ mod tests {
515536
516537 #[ test]
517538 fn parse_error_message_multiple_errors ( ) {
539+ #[ allow( unused_variables) ]
518540 let error = parse_spec ( "crate1::mod1=debug=info,crate2=debug,crate3=invalid" )
519541 . ok ( )
520542 . unwrap_err ( ) ;
543+ #[ cfg( feature = "std" ) ]
521544 assert_data_eq ! (
522545 error,
523546 str ![ "error parsing logger filter: invalid logging spec 'crate1::mod1=debug=info'" ]
0 commit comments