@@ -659,3 +659,37 @@ def test_async_aware_incompatible_with_both_native_and_no_gc(self):
659659 self .assertIn ("--native" , error_msg )
660660 self .assertIn ("--no-gc" , error_msg )
661661 self .assertIn ("incompatible with --async-aware" , error_msg )
662+
663+ def test_async_aware_incompatible_with_mode (self ):
664+ """Test --async-aware is incompatible with --mode (non-wall)."""
665+ test_args = ["profiling.sampling.cli" , "attach" , "12345" , "--async-aware" , "all" , "--mode" , "cpu" ]
666+
667+ with (
668+ mock .patch ("sys.argv" , test_args ),
669+ mock .patch ("sys.stderr" , io .StringIO ()) as mock_stderr ,
670+ self .assertRaises (SystemExit ) as cm ,
671+ ):
672+ from profiling .sampling .cli import main
673+ main ()
674+
675+ self .assertEqual (cm .exception .code , 2 ) # argparse error
676+ error_msg = mock_stderr .getvalue ()
677+ self .assertIn ("--mode=cpu" , error_msg )
678+ self .assertIn ("incompatible with --async-aware" , error_msg )
679+
680+ def test_async_aware_incompatible_with_all_threads (self ):
681+ """Test --async-aware is incompatible with --all-threads."""
682+ test_args = ["profiling.sampling.cli" , "attach" , "12345" , "--async-aware" , "running" , "--all-threads" ]
683+
684+ with (
685+ mock .patch ("sys.argv" , test_args ),
686+ mock .patch ("sys.stderr" , io .StringIO ()) as mock_stderr ,
687+ self .assertRaises (SystemExit ) as cm ,
688+ ):
689+ from profiling .sampling .cli import main
690+ main ()
691+
692+ self .assertEqual (cm .exception .code , 2 ) # argparse error
693+ error_msg = mock_stderr .getvalue ()
694+ self .assertIn ("--all-threads" , error_msg )
695+ self .assertIn ("incompatible with --async-aware" , error_msg )
0 commit comments