@@ -1062,7 +1062,7 @@ impl Cli {
1062
1062
_ => tracing:: Level :: TRACE , // -vvv or more
1063
1063
} ;
1064
1064
1065
- bootc_utils:: update_tracing ( log_level) ;
1065
+ bootc_utils:: update_tracing_log_level ( log_level) ;
1066
1066
1067
1067
cli
1068
1068
}
@@ -1370,15 +1370,16 @@ mod tests {
1370
1370
mod tracing_tests {
1371
1371
#![ allow( unsafe_code) ]
1372
1372
1373
- use bootc_utils:: { initialize_tracing, update_tracing } ;
1373
+ use bootc_utils:: { initialize_tracing, update_tracing_log_level } ;
1374
1374
use nix:: unistd:: { close, dup, dup2, pipe} ;
1375
1375
use std:: fs:: File ;
1376
1376
use std:: io:: { self , Read } ;
1377
1377
use std:: os:: unix:: io:: { AsRawFd , FromRawFd } ;
1378
- use std:: sync:: Once ;
1378
+ use std:: sync:: { Mutex , Once } ;
1379
1379
1380
1380
// Ensure logging is initialized once to prevent conflicts across tests
1381
1381
static INIT : Once = Once :: new ( ) ;
1382
+ static TEST_MUTEX : Mutex < ( ) > = Mutex :: new ( ( ) ) ;
1382
1383
1383
1384
/// Helper function to initialize tracing for tests
1384
1385
fn init_tracing_for_tests ( ) {
@@ -1421,6 +1422,8 @@ mod tracing_tests {
1421
1422
1422
1423
#[ test]
1423
1424
fn test_default_tracing ( ) {
1425
+ let _lock = TEST_MUTEX . lock ( ) . unwrap ( ) ; // Ensure sequential execution
1426
+
1424
1427
init_tracing_for_tests ( ) ;
1425
1428
1426
1429
let output = capture_stderr ( || {
@@ -1435,9 +1438,10 @@ mod tracing_tests {
1435
1438
1436
1439
#[ test]
1437
1440
fn test_update_tracing ( ) {
1441
+ let _lock = TEST_MUTEX . lock ( ) . unwrap ( ) ; // Ensure sequential execution
1442
+
1438
1443
init_tracing_for_tests ( ) ;
1439
- std:: env:: remove_var ( "RUST_LOG" ) ;
1440
- update_tracing ( tracing:: Level :: TRACE ) ;
1444
+ update_tracing_log_level ( tracing:: Level :: TRACE ) ;
1441
1445
1442
1446
let output = capture_stderr ( || {
1443
1447
tracing:: info!( "Info message to stderr" ) ;
@@ -1461,10 +1465,12 @@ mod tracing_tests {
1461
1465
1462
1466
#[ test]
1463
1467
fn test_update_tracing_respects_rust_log ( ) {
1468
+ let _lock = TEST_MUTEX . lock ( ) . unwrap ( ) ; // Ensure sequential execution
1469
+
1464
1470
init_tracing_for_tests ( ) ;
1465
1471
// Set RUST_LOG before initializing(not possible in this test) or after updating tracing
1466
1472
std:: env:: set_var ( "RUST_LOG" , "info" ) ;
1467
- update_tracing ( tracing:: Level :: DEBUG ) ;
1473
+ update_tracing_log_level ( tracing:: Level :: DEBUG ) ;
1468
1474
1469
1475
let output = capture_stderr ( || {
1470
1476
tracing:: info!( "Info message to stderr" ) ;
@@ -1479,5 +1485,7 @@ mod tracing_tests {
1479
1485
!output. contains( "Debug message to stderr" ) ,
1480
1486
"Expected DEBUG message found"
1481
1487
) ;
1488
+
1489
+ std:: env:: remove_var ( "RUST_LOG" ) ;
1482
1490
}
1483
1491
}
0 commit comments