Fix up dspec task for parallelization

This commit is contained in:
Josh Holtrop 2026-01-27 23:41:28 -05:00
parent 9d6321685e
commit baf4e036fb
3 changed files with 14 additions and 11 deletions

View File

@ -29,6 +29,7 @@ task :spec do
end end
task :spec => :build_tests task :spec => :build_tests
task :spec do task :spec do
unless ENV["rscons_dist_specs"]
original_stdout = $stdout original_stdout = $stdout
sio = StringIO.new sio = StringIO.new
$stdout = sio $stdout = sio
@ -37,6 +38,7 @@ task :spec do
sio.string.lines.each do |line| sio.string.lines.each do |line|
$stdout.write(line) unless line =~ /Coverage report generated for/ $stdout.write(line) unless line =~ /Coverage report generated for/
end end
end
end end
task :build_tests do |task, args| task :build_tests do |task, args|
@ -54,6 +56,7 @@ task :dspec, [:example_string] => :build_dist do |task, args|
FileUtils.cp("dist/rscons", "test_run/rscons.rb") FileUtils.cp("dist/rscons", "test_run/rscons.rb")
ENV["rscons_dist_specs"] = "1" ENV["rscons_dist_specs"] = "1"
Rake::Task["spec"].execute(args) Rake::Task["spec"].execute(args)
Rake::Task["build_tests"].execute(args)
ENV.delete("rscons_dist_specs") ENV.delete("rscons_dist_specs")
FileUtils.rm_f(Dir.glob(".rscons-*")) FileUtils.rm_f(Dir.glob(".rscons-*"))
end end

View File

@ -86,7 +86,7 @@ class Test
def run_rscons(options = {}) def run_rscons(options = {})
args = Array(options[:args]) || [] args = Array(options[:args]) || []
if ENV["dist_specs"] if ENV["dist_specs"]
exe = "#{OWD}/test/rscons.rb" exe = "#{OWD}/test_run/rscons.rb"
else else
exe = "#{OWD}/bin/rscons" exe = "#{OWD}/bin/rscons"
end end
@ -248,7 +248,7 @@ def run_tests
tests = @focused_tests.size > 0 ? @focused_tests : @tests tests = @focused_tests.size > 0 ? @focused_tests : @tests
queue = Queue.new queue = Queue.new
threads = {} threads = {}
n_procs = `nproc`.to_i n_procs = `nproc`.to_i * 2
failure = false failure = false
loop do loop do
break if threads.empty? && tests.empty? break if threads.empty? && tests.empty?

View File

@ -1,5 +1,5 @@
if ENV["rscons_dist_specs"] if ENV["rscons_dist_specs"]
require_relative "../test/rscons" require_relative "../test_run/rscons"
else else
require "simplecov" require "simplecov"
@ -15,7 +15,7 @@ else
else else
command_name "RSpec" command_name "RSpec"
end end
add_filter "test/rscons.rb" add_filter "test_run/rscons.rb"
project_name "Rscons" project_name "Rscons"
merge_timeout 3600 merge_timeout 3600
formatter(MyFormatter) formatter(MyFormatter)