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

Split test/natalie/**/*_test.rb files into groups too #2410

Merged
merged 1 commit into from
Dec 23, 2024
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
12 changes: 9 additions & 3 deletions spec/support/split_specs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@
raise 'expected "groupN"' unless num =~ /group(\d+)/
num = $1.to_i - 1

list = Dir['spec/**/*_spec.rb']
slice_size = (list.size / groups.to_f).ceil
raise "expected 1-#{groups}" unless (0...groups.to_i).include?(num)

list = Dir['spec/**/*_spec.rb', 'test/natalie/**/*_test.rb']

rand = Random.new(42)
sorted_list = list.sort_by { |item| rand.rand }

slice_size = (sorted_list.size / groups.to_f).ceil
groups = []
list.each_slice(slice_size).each do |group|
sorted_list.each_slice(slice_size).each do |group|
groups << group
end

Expand Down
11 changes: 10 additions & 1 deletion test/ruby/natalie_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@
parallelize_me!

Dir.chdir File.expand_path('../..', __dir__)
Dir['test/natalie/**/*_test.rb'].each do |path|
files = Dir['test/natalie/**/*_test.rb']

if !(glob = ENV['GLOB']).to_s.empty?
glob_files = files & Dir[*glob.split(',')]
puts "Matched #{glob_files.size} out of #{files.size} total test files:"
puts glob_files.to_a
files = glob_files
end

files.each do |path|
code = File.read(path, encoding: 'utf-8')
describe path do
if code =~ /# skip-ruby/
Expand Down
31 changes: 17 additions & 14 deletions test/ruby/ruby_specs_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ def spec_timeout(path)
end

Dir.chdir File.expand_path('../..', __dir__)
glob = if ENV['DEBUG_COMPILER']
# I use this when I'm working on the compiler,
# as it catches 99% of bugs and finishes a lot quicker.
Dir['spec/language/*_spec.rb']
elsif !(glob = ENV['GLOB']).to_s.empty?
# GLOB="spec/core/io/*_spec.rb,spec/core/thread/*_spec.rb" rake test
Dir[*glob.split(',')].tap do |files|
puts 'Matched files:'
puts files.to_a
end
else
Dir['spec/**/*_spec.rb']
end
glob.each do |path|
files = if ENV['DEBUG_COMPILER']
# I use this when I'm working on the compiler,
# as it catches 99% of bugs and finishes a lot quicker.
Dir['spec/language/*_spec.rb']
else
Dir['spec/**/*_spec.rb']
end

if !(glob = ENV['GLOB']).to_s.empty?
# GLOB="spec/core/io/*_spec.rb,spec/core/thread/*_spec.rb" rake test
glob_files = files & Dir[*glob.split(',')]
puts "Matched #{glob_files.size} out of #{files.size} total spec files:"
puts glob_files.to_a
files = glob_files
end

files.each do |path|
describe path do
it 'passes all specs' do
out_nat = Timeout.timeout(spec_timeout(path), nil, "execution expired running: #{path}") do
Expand Down
Loading