Skip to content

Commit 8b9a85e

Browse files
committed
Make threads assertion order-agnostic
1 parent 1119e37 commit 8b9a85e

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ Please note that both `value` and `type` need to be strings.
376376

377377
Passes if both conditions are true:
378378

379-
1. The number of expected pattern matches the number of threads.
380-
2. The expected patterns match the thread names in the given order.
379+
1. The number of expected patterns matches the number of threads.
380+
2. Every pattern matches a thread name. Notice that the order of threads info is not guaranteed.
381381

382382
Example:
383383

test/support/protocol_utils.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,22 @@ def assert_threads_result(expected_names)
234234
case ENV['RUBY_DEBUG_TEST_UI']
235235
when 'vscode'
236236
res = send_dap_request 'threads'
237+
failure_msg = FailureMessage.new{create_protocol_message "result:\n#{JSON.pretty_generate res}."}
237238

238239
threads = res.dig(:body, :threads)
239-
failure_msg = FailureMessage.new{create_protocol_message "result:\n#{JSON.pretty_generate res}"}
240240

241241
assert_equal expected_names.count, threads.count, failure_msg
242242

243-
expected_names.each_with_index do |expected, index|
244-
assert_match expected, threads[index][:name], failure_msg
243+
thread_names = threads.map { |t| t[:name] }
244+
245+
expected_names.each do |expected|
246+
thread_names.reject! do |name|
247+
name.match?(expected)
248+
end
245249
end
250+
251+
failure_msg = FailureMessage.new{create_protocol_message "result:\n#{JSON.pretty_generate res}.\nExpect all thread names to be matched. Unmatched threads:"}
252+
assert_equal [], thread_names, failure_msg
246253
end
247254
end
248255

0 commit comments

Comments
 (0)