summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-07 12:44:55 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-07 13:43:50 +0900
commita3fb97465df3a4b6a7f56a1a915c6239a2a303b9 (patch)
tree314d40fb0263d9c6f73d22b3ff5e3cb3a2e7d53e /tool
parent3d21a75c72586baee75ab9b9c5335c755ee76793 (diff)
Stop auto runner
Auto runner should not run in forked processes in separated tests.
Diffstat (limited to 'tool')
-rw-r--r--tool/lib/test/unit/core_assertions.rb24
1 files changed, 13 insertions, 11 deletions
diff --git a/tool/lib/test/unit/core_assertions.rb b/tool/lib/test/unit/core_assertions.rb
index 5b65eb9960..86ed37f078 100644
--- a/tool/lib/test/unit/core_assertions.rb
+++ b/tool/lib/test/unit/core_assertions.rb
@@ -104,6 +104,14 @@ module Test
ABORT_SIGNALS = Signal.list.values_at(*%w"ILL ABRT BUS SEGV TERM")
+ def separated_runner(out = nil)
+ out = out ? IO.new(out, 'w') : STDOUT
+ at_exit {
+ out.puts [Marshal.dump($!)].pack('m'), "assertions=\#{self._assertions}"
+ }
+ Test::Unit::Runner.class_variable_set(:@@stop_auto_run, true)
+ end
+
def assert_separately(args, file = nil, line = nil, src, ignore_stderr: nil, **opt)
unless file and line
loc, = caller_locations(1,1)
@@ -111,25 +119,19 @@ module Test
line ||= loc.lineno
end
capture_stdout = true
- if /mswin|mingw/ =~ RUBY_PLATFORM
- res_out = "STDOUT"
- else
+ unless /mswin|mingw/ =~ RUBY_PLATFORM
capture_stdout = false
opt[:out] = MiniTest::Unit.output
res_p, res_c = IO.pipe
opt[res_c.fileno] = res_c.fileno
- res_out = "IO.new(#{res_c.fileno}, 'w')"
end
src = <<eom
# -*- coding: #{line += __LINE__; src.encoding}; -*-
- require "test/unit";out=#{res_out};include Test::Unit::Assertions;require #{(__dir__ + "/core_assertions").dump};include Test::Unit::CoreAssertions
- END {
- out.puts [Marshal.dump($!)].pack('m'), "assertions=\#{self._assertions}"
- }
+BEGIN {
+ require "test/unit";include Test::Unit::Assertions;require #{(__dir__ + "/core_assertions").dump};include Test::Unit::CoreAssertions
+ separated_runner #{res_c&.fileno}
+}
#{line -= __LINE__; src}
- class Test::Unit::Runner
- @@stop_auto_run = true
- end
eom
args = args.dup
args.insert((Hash === args.first ? 1 : 0), "-w", "--disable=gems", *$:.map {|l| "-I#{l}"})