Skip to content

Commit

Permalink
Make test less flaky.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Feb 18, 2024
1 parent 0e0d434 commit 0160017
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions tests_python/resources/_debugger_case_multi_threads_stepping.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'''
"""
After breaking on the thread 1, thread 2 should pause waiting for the event1 to be set,
so, when we step return on thread 1, the program should finish if all threads are resumed
or should keep waiting for the thread 2 to run if only thread 1 is resumed.
'''
"""

import threading

Expand All @@ -17,13 +17,13 @@ def _thread1():
_event2_set = False

while not event0.is_set():
event0.wait(timeout=.001)
event0.wait(timeout=0.001)

event1.set() # Break thread 1
_event1_set = True

while not event2.is_set():
event2.wait(timeout=.001)
event2.wait(timeout=0.001)
_event2_set = True # Note: we can only get here if thread 2 is also released.

event3.set()
Expand All @@ -33,23 +33,23 @@ def _thread2():
event0.set()

while not event1.is_set():
event1.wait(timeout=.001)
event1.wait(timeout=0.001)

event2.set()

while not event3.is_set():
event3.wait(timeout=.001)
event3.wait(timeout=0.001)


if __name__ == '__main__':
if __name__ == "__main__":
threads = [
threading.Thread(target=_thread1, name='thread1'),
threading.Thread(target=_thread2, name='thread2'),
threading.Thread(target=_thread1, name="thread1"),
threading.Thread(target=_thread2, name="thread2"),
]
for t in threads:
t.start()

for t in threads:
t.join()

print('TEST SUCEEDED!')
print("TEST SUCEEDED!")
6 changes: 3 additions & 3 deletions tests_python/test_debugger_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -3192,7 +3192,7 @@ def test_step_next_step_in_multi_threads(case_setup_dap, stepping_resumes_all_th
with case_setup_dap.test_file("_debugger_case_multi_threads_stepping.py") as writer:
json_facade = JsonFacade(writer)

json_facade.write_launch(steppingResumesAllThreads=stepping_resumes_all_threads)
json_facade.write_launch(steppingResumesAllThreads=stepping_resumes_all_threads, justMyCode=True)
json_facade.write_set_breakpoints(
[
writer.get_line_index_with_content("Break thread 1"),
Expand All @@ -3208,7 +3208,7 @@ def test_step_next_step_in_multi_threads(case_setup_dap, stepping_resumes_all_th
thread_name_to_id = dict((t["name"], t["id"]) for t in response.body.threads)
assert json_hit.thread_id == thread_name_to_id["thread1"]

for _i in range(30):
for _i in range(15):
if step_mode == "step_next":
json_facade.write_step_next(thread_name_to_id["thread1"])

Expand All @@ -3230,7 +3230,7 @@ def test_step_next_step_in_multi_threads(case_setup_dap, stepping_resumes_all_th
else:
raise AssertionError("Did not expect _event2_set to be set when not resuming other threads on step.")

time.sleep(0.02)
time.sleep(0.01)
else:
if stepping_resumes_all_threads:
raise AssertionError("Expected _event2_set to be set already.")
Expand Down

0 comments on commit 0160017

Please sign in to comment.