Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve skip test message #1476

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,22 @@ def assert_sampling_check(builder, sample_size, array)
OptionParser.new do |opts|
opts.on("--name NAME") do |name|
name = name.gsub(/(\A\/)|(\/\Z)/, '')
klass_name, method_name = name.split("#", 2)

constant = (Object.const_get(name) rescue nil)
constant = ObjectSpace.each_object(Class).find do |klass|
if klass.name
klass.name == klass_name || klass.name.end_with?("::#{klass_name}")
end
end

if constant
test_unit_args << "--testcase"
test_unit_args << name
else
test_unit_args << "--name"
test_unit_args << name
if method_name
test_unit_args << "--name"
test_unit_args << "#{constant.name}##{method_name}"
else
test_unit_args << "--testcase"
test_unit_args << constant.name
end
end
end
end.order!(argv)
Expand Down
5 changes: 4 additions & 1 deletion test/test_skip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def setup
end

def teardown
unless current_result.passed?
case
when passed?
# nop
else
puts "💡You can skip this test `#{name}` by adding the name to `#{SKIP_TESTS_FILE}`"
end

Expand Down