@@ -459,20 +459,28 @@ mod tests {
459
459
460
460
#[ test]
461
461
fn test_graph_empty ( ) {
462
+ // cargo test by default will run all test functions in parallel using
463
+ // as many threads as the underlying system allows. However, the test
464
+ // expectations of test_graph_empty will fail if its detects any other middleware
465
+ // activity while it's running.
466
+ //
467
+ // If we ensure that the Context of test_graph_empty is given a different domain ID
468
+ // from the rest of the tests, then we can ensure that it will not observe any other
469
+ // middleware activity, and its expectations can pass (as long as the user is not
470
+ // running any other ROS executables on their system).
471
+ //
472
+ // By default we will assign 99 to the domain ID of test_graph_empty's Context.
473
+ // However, if the ROS_DOMAIN_ID environment variable was set to 99 by the user,
474
+ // then the rest of the tests will be using that value. So here we are detecting
475
+ // that situation and setting the domain ID of test_graph_empty's Context to 98
476
+ // in that situation.
477
+ //
478
+ // 99 and 98 are just chosen as arbitrary valid domain ID values. There is
479
+ // otherwise nothing special about either value.
462
480
let domain_id: usize = std:: env:: var ( "ROS_DOMAIN_ID" )
463
481
. ok ( )
464
482
. and_then ( |value| value. parse ( ) . ok ( ) )
465
- . map ( |value : usize | {
466
- if value == 99 {
467
- // The default domain ID for this application is 99, which
468
- // conflicts with our arbitrarily chosen default for the
469
- // empty graph test. Therefore we will set the empty graph
470
- // test domain ID to 98 instead.
471
- 98
472
- } else {
473
- 99
474
- }
475
- } )
483
+ . map ( |value : usize | if value != 99 { 99 } else { 98 } )
476
484
. unwrap_or ( 99 ) ;
477
485
478
486
let context =
0 commit comments