if hasattr(args, 'live') and args.live:
parser.error("--subprocesses is incompatible with --live mode.")
- # Async-aware mode is incompatible with --native, --no-gc, --mode, and --all-threads
+ # Async-aware mode is incompatible with options that need thread data.
if getattr(args, 'async_aware', False):
issues = []
if getattr(args, 'native', False):
issues.append("--native")
if not getattr(args, 'gc', True):
issues.append("--no-gc")
+ if getattr(args, 'format', None) == "binary":
+ issues.append("--binary")
if hasattr(args, 'mode') and args.mode != "wall":
issues.append(f"--mode={args.mode}")
if hasattr(args, 'all_threads') and args.all_threads:
self.assertIn("--all-threads", error_msg)
self.assertIn("incompatible with --async-aware", error_msg)
+ def test_async_aware_incompatible_with_binary(self):
+ """Test --async-aware is incompatible with --binary."""
+ test_args = ["profiling.sampling.cli", "attach", "12345",
+ "--async-aware", "--binary"]
+
+ with (
+ mock.patch("sys.argv", test_args),
+ mock.patch("sys.stderr", io.StringIO()) as mock_stderr,
+ self.assertRaises(SystemExit) as cm,
+ ):
+ main()
+
+ self.assertEqual(cm.exception.code, 2) # argparse error
+ error_msg = mock_stderr.getvalue()
+ self.assertIn("--binary", error_msg)
+ self.assertIn("incompatible with --async-aware", error_msg)
+
@unittest.skipIf(is_emscripten, "subprocess not available")
def test_run_nonexistent_script_exits_cleanly(self):
"""Test that running a non-existent script exits with a clean error."""