mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test/unit.rb: share job slots
* test/lib/test/unit.rb (Test::Unit::Parallel#_run_parallel): share job slots with GNU 'make'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
953093e2a4
commit
0fe47fad55
3 changed files with 40 additions and 6 deletions
12
common.mk
12
common.mk
|
@ -11,6 +11,8 @@ Q = $(Q1:0=@)
|
||||||
ECHO0 = $(ECHO1:0=echo)
|
ECHO0 = $(ECHO1:0=echo)
|
||||||
ECHO = @$(ECHO0)
|
ECHO = @$(ECHO0)
|
||||||
|
|
||||||
|
gnumake_recursive =
|
||||||
|
|
||||||
UNICODE_VERSION = 9.0.0
|
UNICODE_VERSION = 9.0.0
|
||||||
|
|
||||||
### set the following environment variable or uncomment the line if
|
### set the following environment variable or uncomment the line if
|
||||||
|
@ -624,7 +626,7 @@ yes-test-knownbug: prog PHONY
|
||||||
|
|
||||||
test-testframework: $(TEST_RUNNABLE)-test-testframework
|
test-testframework: $(TEST_RUNNABLE)-test-testframework
|
||||||
yes-test-testframework: prog PHONY
|
yes-test-testframework: prog PHONY
|
||||||
$(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" $(TESTOPTS) testunit minitest
|
$(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" $(TESTOPTS) testunit minitest
|
||||||
no-test-testframework: PHONY
|
no-test-testframework: PHONY
|
||||||
|
|
||||||
test-sample: test-basic # backward compatibility for mswin-build
|
test-sample: test-basic # backward compatibility for mswin-build
|
||||||
|
@ -634,20 +636,20 @@ test: btest-ruby test-knownbug test-basic
|
||||||
# for example, make test-all TESTOPTS="-j2 -v -n test-name -- test-file-name"
|
# for example, make test-all TESTOPTS="-j2 -v -n test-name -- test-file-name"
|
||||||
test-all: $(TEST_RUNNABLE)-test-all
|
test-all: $(TEST_RUNNABLE)-test-all
|
||||||
yes-test-all: prog PHONY
|
yes-test-all: prog PHONY
|
||||||
$(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS)
|
$(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS)
|
||||||
TESTS_BUILD = mkmf
|
TESTS_BUILD = mkmf
|
||||||
no-test-all: PHONY
|
no-test-all: PHONY
|
||||||
$(MINIRUBY) -I"$(srcdir)/lib" "$(srcdir)/test/runner.rb" $(TESTOPTS) $(TESTS_BUILD)
|
$(gnumake_recursive)$(MINIRUBY) -I"$(srcdir)/lib" "$(srcdir)/test/runner.rb" $(TESTOPTS) $(TESTS_BUILD)
|
||||||
|
|
||||||
test-almost: $(TEST_RUNNABLE)-test-almost
|
test-almost: $(TEST_RUNNABLE)-test-almost
|
||||||
yes-test-almost: prog PHONY
|
yes-test-almost: prog PHONY
|
||||||
$(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(EXCLUDE_TESTFRAMEWORK) $(TESTS)
|
$(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(EXCLUDE_TESTFRAMEWORK) $(TESTS)
|
||||||
no-test-almost: PHONY
|
no-test-almost: PHONY
|
||||||
|
|
||||||
test-ruby: $(TEST_RUNNABLE)-test-ruby
|
test-ruby: $(TEST_RUNNABLE)-test-ruby
|
||||||
no-test-ruby: PHONY
|
no-test-ruby: PHONY
|
||||||
yes-test-ruby: prog encs PHONY
|
yes-test-ruby: prog encs PHONY
|
||||||
$(RUNRUBY) "$(srcdir)/test/runner.rb" $(TEST_EXCLUDES) $(TESTOPTS) -- ruby -ext-
|
$(gnumake_recursive)$(RUNRUBY) "$(srcdir)/test/runner.rb" $(TEST_EXCLUDES) $(TESTOPTS) -- ruby -ext-
|
||||||
|
|
||||||
extconf: $(PREP)
|
extconf: $(PREP)
|
||||||
$(Q) $(MAKEDIRS) "$(EXTCONFDIR)"
|
$(Q) $(MAKEDIRS) "$(EXTCONFDIR)"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# -*- makefile-gmake -*-
|
# -*- makefile-gmake -*-
|
||||||
gnumake = yes
|
gnumake = yes
|
||||||
|
override gnumake_recursive := +
|
||||||
|
|
||||||
CHECK_TARGETS := exam love check%
|
CHECK_TARGETS := exam love check%
|
||||||
TEST_TARGETS := $(filter check test check% test% btest%,$(MAKECMDGOALS))
|
TEST_TARGETS := $(filter check test check% test% btest%,$(MAKECMDGOALS))
|
||||||
|
|
|
@ -134,6 +134,23 @@ module Test
|
||||||
options
|
options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def non_options(files, options)
|
||||||
|
if !options[:parallel] and
|
||||||
|
/(?:\A|\s)--jobserver-auth=(\d+),(\d+)/ =~ ENV["MAKEFLAGS"]
|
||||||
|
begin
|
||||||
|
r = IO.for_fd($1.to_i(10), "rb", autoclose: false)
|
||||||
|
w = IO.for_fd($2.to_i(10), "wb", autoclose: false)
|
||||||
|
rescue
|
||||||
|
r.close if r
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
@jobserver = [r, w]
|
||||||
|
options[:parallel] ||= 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
def status(*args)
|
def status(*args)
|
||||||
result = super
|
result = super
|
||||||
raise @interrupt if @interrupt
|
raise @interrupt if @interrupt
|
||||||
|
@ -173,9 +190,11 @@ module Test
|
||||||
|
|
||||||
class Worker
|
class Worker
|
||||||
def self.launch(ruby,args=[])
|
def self.launch(ruby,args=[])
|
||||||
|
opts = {}
|
||||||
|
@jobserver.each {|fd| opts[fd] = fd} if @jobserver
|
||||||
io = IO.popen([*ruby, "-W1",
|
io = IO.popen([*ruby, "-W1",
|
||||||
"#{File.dirname(__FILE__)}/unit/parallel.rb",
|
"#{File.dirname(__FILE__)}/unit/parallel.rb",
|
||||||
*args], "rb+")
|
*args], "rb+", opts)
|
||||||
new(io, io.pid, :waiting)
|
new(io, io.pid, :waiting)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -417,6 +436,7 @@ module Test
|
||||||
@workers = [] # Array of workers.
|
@workers = [] # Array of workers.
|
||||||
@workers_hash = {} # out-IO => worker
|
@workers_hash = {} # out-IO => worker
|
||||||
@ios = [] # Array of worker IOs
|
@ios = [] # Array of worker IOs
|
||||||
|
job_tokens = String.new(encoding: Encoding::ASCII_8BIT) if @jobserver
|
||||||
begin
|
begin
|
||||||
[@tasks.size, @options[:parallel]].min.times {launch_worker}
|
[@tasks.size, @options[:parallel]].min.times {launch_worker}
|
||||||
|
|
||||||
|
@ -426,6 +446,13 @@ module Test
|
||||||
(deal(io, type, result, rep).nil? and
|
(deal(io, type, result, rep).nil? and
|
||||||
!@workers.any? {|x| [:running, :prepare].include? x.status})
|
!@workers.any? {|x| [:running, :prepare].include? x.status})
|
||||||
end
|
end
|
||||||
|
if job_tokens and !@tasks.empty? and !@workers.any? {|x| x.status == :ready}
|
||||||
|
t = @jobserver[0].read_nonblock([@tasks.size, @options[:parallel]].min, exception: false)
|
||||||
|
if String === t
|
||||||
|
job_tokens << t
|
||||||
|
t.size.times {launch_worker}
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
rescue Interrupt => ex
|
rescue Interrupt => ex
|
||||||
@interrupt = ex
|
@interrupt = ex
|
||||||
|
@ -439,6 +466,10 @@ module Test
|
||||||
end
|
end
|
||||||
|
|
||||||
quit_workers
|
quit_workers
|
||||||
|
if @jobserver
|
||||||
|
@jobserver[1] << job_tokens
|
||||||
|
job_tokens.clear
|
||||||
|
end
|
||||||
|
|
||||||
unless @interrupt || !@options[:retry] || @need_quit
|
unless @interrupt || !@options[:retry] || @need_quit
|
||||||
parallel = @options[:parallel]
|
parallel = @options[:parallel]
|
||||||
|
|
Loading…
Reference in a new issue