mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Let other test runners follow the change of GNU make 4.4 jobserver
This commit is contained in:
parent
ab01b8f23f
commit
b02b8e7756
3 changed files with 31 additions and 9 deletions
|
@ -108,10 +108,16 @@ BT = Class.new(bt) do
|
||||||
|
|
||||||
def wn=(wn)
|
def wn=(wn)
|
||||||
unless wn == 1
|
unless wn == 1
|
||||||
if /(?:\A|\s)--jobserver-(?:auth|fds)=\K(\d+),(\d+)/ =~ ENV.delete("MAKEFLAGS")
|
if /(?:\A|\s)--jobserver-(?:auth|fds)=(?:(\d+),(\d+)|fifo:((?:\\.|\S)+))/ =~ ENV.delete("MAKEFLAGS")
|
||||||
begin
|
begin
|
||||||
r = IO.for_fd($1.to_i(10), "rb", autoclose: false)
|
if fifo = $3
|
||||||
w = IO.for_fd($2.to_i(10), "wb", autoclose: false)
|
fifo.gsub!(/\\(?=.)/, '')
|
||||||
|
r = File.open(fifo, IO::RDONLY|IO::NONBLOCK|IO::BINARY)
|
||||||
|
w = File.open(fifo, IO::WRONLY|IO::NONBLOCK|IO::BINARY)
|
||||||
|
else
|
||||||
|
r = IO.for_fd($1.to_i(10), "rb", autoclose: false)
|
||||||
|
w = IO.for_fd($2.to_i(10), "wb", autoclose: false)
|
||||||
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
r.close if r
|
r.close if r
|
||||||
else
|
else
|
||||||
|
|
|
@ -29,11 +29,19 @@ end
|
||||||
|
|
||||||
module MSpecScript::JobServer
|
module MSpecScript::JobServer
|
||||||
def cores(max = 1)
|
def cores(max = 1)
|
||||||
if max > 1 and /(?:\A|\s)--jobserver-(?:auth|fds)=(\d+),(\d+)/ =~ ENV["MAKEFLAGS"]
|
if max > 1 and /(?:\A|\s)--jobserver-(?:auth|fds)=(?:(\d+),(\d+)|fifo:((?:\\.|\S)+))/ =~ ENV["MAKEFLAGS"]
|
||||||
cores = 1
|
cores = 1
|
||||||
begin
|
begin
|
||||||
r = IO.for_fd($1.to_i(10), "rb", autoclose: false)
|
if fifo = $3
|
||||||
w = IO.for_fd($2.to_i(10), "wb", autoclose: false)
|
fifo.gsub!(/\\(?=.)/, '')
|
||||||
|
r = File.open(fifo, IO::RDONLY|IO::NONBLOCK|IO::BINARY)
|
||||||
|
w = File.open(fifo, IO::WRONLY|IO::NONBLOCK|IO::BINARY)
|
||||||
|
else
|
||||||
|
r = IO.for_fd($1.to_i(10), "rb", autoclose: false)
|
||||||
|
w = IO.for_fd($2.to_i(10), "wb", autoclose: false)
|
||||||
|
end
|
||||||
|
r.close_on_exec = true
|
||||||
|
w.close_on_exec = true
|
||||||
jobtokens = r.read_nonblock(max - 1)
|
jobtokens = r.read_nonblock(max - 1)
|
||||||
cores = jobtokens.size
|
cores = jobtokens.size
|
||||||
if cores > 0
|
if cores > 0
|
||||||
|
|
|
@ -113,12 +113,20 @@ def setup_make
|
||||||
end
|
end
|
||||||
|
|
||||||
opts = {}
|
opts = {}
|
||||||
if /(?:\A|\s)--jobserver-(?:auth|fds)=(\d+),(\d+)/ =~ make_flags
|
if /(?:\A|\s)--jobserver-(?:auth|fds)=(?:(\d+),(\d+)|fifo:((?:\\.|\S)+))/ =~ make_flags
|
||||||
begin
|
begin
|
||||||
r = IO.for_fd($1.to_i(10), "rb", autoclose: false)
|
if fifo = $3
|
||||||
w = IO.for_fd($2.to_i(10), "wb", autoclose: false)
|
fifo.gsub!(/\\(?=.)/, '')
|
||||||
|
r = File.open(fifo, IO::RDONLY|IO::NONBLOCK|IO::BINARY)
|
||||||
|
w = File.open(fifo, IO::WRONLY|IO::NONBLOCK|IO::BINARY)
|
||||||
|
else
|
||||||
|
r = IO.for_fd($1.to_i(10), "rb", autoclose: false)
|
||||||
|
w = IO.for_fd($2.to_i(10), "wb", autoclose: false)
|
||||||
|
end
|
||||||
rescue Errno::EBADF
|
rescue Errno::EBADF
|
||||||
else
|
else
|
||||||
|
r.close_on_exec = true
|
||||||
|
w.close_on_exec = true
|
||||||
opts[r] = r
|
opts[r] = r
|
||||||
opts[w] = w
|
opts[w] = w
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue