Fix up dspec task for parallelization

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

View File

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

View File

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

View File

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