Skip to content

Commit 5849aad

Browse files
committed
profiling(gecko): add main_thread_id to MockInterpreter and add check in Gecko test
Signed-off-by: Sofia Donato Ferreira <flowlnlnln@gmail.com>
1 parent f186d3f commit 5849aad

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

Lib/test/test_profiling/test_sampling_profiler/mocks.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ def __repr__(self):
5050
class MockInterpreterInfo:
5151
"""Mock InterpreterInfo for testing since the real one isn't accessible."""
5252

53-
def __init__(self, interpreter_id, threads):
53+
def __init__(self, interpreter_id, threads, main_thread_id=None):
5454
self.interpreter_id = interpreter_id
55+
self.main_thread_id = main_thread_id
5556
self.threads = threads
5657

5758
def __repr__(self):
58-
return f"MockInterpreterInfo(interpreter_id={self.interpreter_id}, threads={self.threads})"
59+
return f"MockInterpreterInfo(interpreter_id={self.interpreter_id}, main_thread_id={self.main_thread_id}, threads={self.threads})"
5960

6061

6162
class MockCoroInfo:

Lib/test/test_profiling/test_sampling_profiler/test_collectors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ def test_gecko_collector_basic(self):
526526
[MockFrameInfo("file.py", 10, "func1"), MockFrameInfo("file.py", 20, "func2")],
527527
)
528528
],
529+
main_thread_id=1,
529530
)
530531
]
531532
collector.collect(test_frames)
@@ -556,6 +557,7 @@ def test_gecko_collector_basic(self):
556557
threads = profile_data["threads"]
557558
self.assertEqual(len(threads), 1)
558559
thread_data = threads[0]
560+
self.assertTrue(thread_data["isMainThread"])
559561

560562
# Verify thread structure
561563
self.assertIn("samples", thread_data)

0 commit comments

Comments
 (0)