def test_stop_on_hit_condition(debugger_api: _DebuggerAPI): from robocorp_ls_core.debug_adapter_core.dap.dap_schema import TerminatedEvent debugger_api.initialize() target = debugger_api.get_dap_case_file("case_condition.robot") debugger_api.target = target debugger_api.launch(target, debug=True) line = debugger_api.get_line_index_with_content("Log ${counter}") debugger_api.set_breakpoints(target, line, line_to_kwargs={line: { "hitCondition": "2" }}) debugger_api.configuration_done() json_hit = debugger_api.wait_for_thread_stopped(name="Log") name_to_scope = debugger_api.get_name_to_scope(json_hit.frame_id) assert sorted( name_to_scope.keys()) == ["Arguments", "Builtins", "Variables"] name_to_var = debugger_api.get_variables_name_to_var(json_hit.frame_id) assert name_to_var["'${counter}'"].value == "2" msg = debugger_api.continue_event(json_hit.thread_id, accept_terminated=True) if not isinstance(msg, TerminatedEvent): debugger_api.read(TerminatedEvent)
def test_variables(debugger_api: _DebuggerAPI): from robocorp_ls_core.debug_adapter_core.dap.dap_schema import TerminatedEvent debugger_api.initialize() target = debugger_api.get_dap_case_file("case4/case4.robot") debugger_api.target = target debugger_api.launch(target, debug=True, args=["--variable", "my_var:22"]) debugger_api.set_breakpoints( target, debugger_api.get_line_index_with_content("My Equal Redefined 2 2")) debugger_api.configuration_done() json_hit = debugger_api.wait_for_thread_stopped(name="My Equal Redefined") name_to_scope = debugger_api.get_name_to_scope(json_hit.frame_id) assert sorted( name_to_scope.keys()) == ["Arguments", "Builtins", "Variables"] name_to_var = debugger_api.get_arguments_name_to_var(json_hit.frame_id) assert sorted(name_to_var.keys()) == ["Arg 0", "Arg 1"] name_to_var = debugger_api.get_variables_name_to_var(json_hit.frame_id) assert "'${TEST_NAME}'" not in name_to_var assert "'${arg1}'" not in name_to_var assert "'${my_var}'" in name_to_var name_to_var = debugger_api.get_builtins_name_to_var(json_hit.frame_id) assert "'${TEST_NAME}'" in name_to_var assert "'${arg1}'" not in name_to_var assert "'${my_var}'" not in name_to_var debugger_api.step_in(json_hit.thread_id) # Check that the 'arg1' var is in the current namespace but not in the parent # namespace. json_hit = debugger_api.wait_for_thread_stopped("step", name="Should Be Equal") name_to_var = debugger_api.get_variables_name_to_var(json_hit.frame_id) assert "'${arg1}'" in name_to_var or "u'${arg1}'" in name_to_var name_to_var = debugger_api.get_variables_name_to_var( json_hit.stack_trace_response.body.stackFrames[1]["id"]) assert "'${arg1}'" not in name_to_var and "u'${arg1}'" not in name_to_var debugger_api.continue_event() debugger_api.read(TerminatedEvent)