From 0160017b69281b1a1524316e72cb98223666dd56 Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Sun, 18 Feb 2024 10:29:55 -0300 Subject: [PATCH] Make test less flaky. --- .../_debugger_case_multi_threads_stepping.py | 20 +++++++++---------- tests_python/test_debugger_json.py | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests_python/resources/_debugger_case_multi_threads_stepping.py b/tests_python/resources/_debugger_case_multi_threads_stepping.py index be1eeb3cf..b275a974a 100644 --- a/tests_python/resources/_debugger_case_multi_threads_stepping.py +++ b/tests_python/resources/_debugger_case_multi_threads_stepping.py @@ -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 @@ -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() @@ -33,18 +33,18 @@ 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() @@ -52,4 +52,4 @@ def _thread2(): for t in threads: t.join() - print('TEST SUCEEDED!') + print("TEST SUCEEDED!") diff --git a/tests_python/test_debugger_json.py b/tests_python/test_debugger_json.py index 762ff09b6..084ecc772 100644 --- a/tests_python/test_debugger_json.py +++ b/tests_python/test_debugger_json.py @@ -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"), @@ -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"]) @@ -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.")