|
19 | 19 | _cleanup_process, |
20 | 20 | ) |
21 | 21 |
|
| 22 | +# String to check for in stderr when profiler lacks permissions (e.g., macOS) |
| 23 | +_PERMISSION_ERROR_MSG = "Permission Error" |
| 24 | +_SKIP_PERMISSION_MSG = "Insufficient permissions for remote profiling" |
| 25 | + |
22 | 26 |
|
23 | 27 | def _readline_with_timeout(file_obj, timeout): |
24 | 28 | # Thread-based readline with timeout - works across all platforms |
@@ -580,9 +584,12 @@ def test_is_python_process_python_subprocess(self): |
580 | 584 | while time.time() < deadline: |
581 | 585 | if proc.poll() is not None: |
582 | 586 | self.fail(f"Process {proc.pid} exited unexpectedly") |
583 | | - if is_python_process(proc.pid): |
584 | | - detected = True |
585 | | - break |
| 587 | + try: |
| 588 | + if is_python_process(proc.pid): |
| 589 | + detected = True |
| 590 | + break |
| 591 | + except PermissionError: |
| 592 | + self.skipTest(_SKIP_PERMISSION_MSG) |
586 | 593 | time.sleep(0.05) |
587 | 594 |
|
588 | 595 | self.assertTrue( |
@@ -947,6 +954,9 @@ def test_subprocesses_flag_spawns_child_and_creates_output(self): |
947 | 954 | timeout=SHORT_TIMEOUT, |
948 | 955 | ) |
949 | 956 |
|
| 957 | + if _PERMISSION_ERROR_MSG in result.stderr: |
| 958 | + self.skipTest(_SKIP_PERMISSION_MSG) |
| 959 | + |
950 | 960 | # Check that parent output file was created |
951 | 961 | self.assertTrue( |
952 | 962 | os.path.exists(output_file), |
@@ -1010,6 +1020,9 @@ def test_subprocesses_flag_with_flamegraph_output(self): |
1010 | 1020 | timeout=SHORT_TIMEOUT, |
1011 | 1021 | ) |
1012 | 1022 |
|
| 1023 | + if _PERMISSION_ERROR_MSG in result.stderr: |
| 1024 | + self.skipTest(_SKIP_PERMISSION_MSG) |
| 1025 | + |
1013 | 1026 | self.assertTrue( |
1014 | 1027 | os.path.exists(output_file), |
1015 | 1028 | f"Flamegraph output not created. stderr: {result.stderr}", |
@@ -1063,6 +1076,9 @@ def test_subprocesses_flag_no_crash_on_quick_child(self): |
1063 | 1076 | timeout=SHORT_TIMEOUT, |
1064 | 1077 | ) |
1065 | 1078 |
|
| 1079 | + if _PERMISSION_ERROR_MSG in result.stderr: |
| 1080 | + self.skipTest(_SKIP_PERMISSION_MSG) |
| 1081 | + |
1066 | 1082 | # Should not crash - exit code 0 |
1067 | 1083 | self.assertEqual( |
1068 | 1084 | result.returncode, |
|
0 commit comments