summaryrefslogtreecommitdiff
path: root/spec/mspec/lib/mspec/commands/mspec.rb
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-25 18:47:17 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-25 18:47:17 +0000
commite2d74af38b0a5329615e03f964acf01cd0266782 (patch)
tree611b633b9761ad505e5faa43f9f4505d34cfc6c5 /spec/mspec/lib/mspec/commands/mspec.rb
parent2466288d27eba50a6a68bd00f854b5a7687745ae (diff)
Update to ruby/mspec@2bca8cb
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/mspec/lib/mspec/commands/mspec.rb')
-rwxr-xr-xspec/mspec/lib/mspec/commands/mspec.rb65
1 files changed, 3 insertions, 62 deletions
diff --git a/spec/mspec/lib/mspec/commands/mspec.rb b/spec/mspec/lib/mspec/commands/mspec.rb
index 6cb1e87a58..0ccea82a5c 100755
--- a/spec/mspec/lib/mspec/commands/mspec.rb
+++ b/spec/mspec/lib/mspec/commands/mspec.rb
@@ -89,72 +89,13 @@ class MSpecMain < MSpecScript
def register; end
def multi_exec(argv)
- MSpec.register_files @files
-
require 'mspec/runner/formatters/multi'
formatter = MultiFormatter.new
- if config[:formatter]
- warn "formatter options is ignored due to multi option"
- end
+ warn "formatter options is ignored due to multi option" if config[:formatter]
- output_files = []
+ require 'mspec/runner/parallel'
processes = cores(@files.size)
- children = processes.times.map { |i|
- name = tmp "mspec-multi-#{i}"
- output_files << name
-
- env = {
- "SPEC_TEMP_DIR" => "rubyspec_temp_#{i}",
- "MSPEC_MULTI" => i.to_s
- }
- command = argv + ["-fy", "-o", name]
- $stderr.puts "$ #{command.join(' ')}" if $MSPEC_DEBUG
- IO.popen([env, *command, close_others: false], "rb+")
- }
-
- puts children.map { |child| child.gets }.uniq
- formatter.start
- last_files = {}
-
- until @files.empty?
- IO.select(children)[0].each { |io|
- reply = io.read(1)
- case reply
- when '.'
- formatter.unload
- when nil
- raise "Worker died!"
- else
- while chunk = (io.read_nonblock(4096) rescue nil)
- reply += chunk
- end
- reply.chomp!('.')
- msg = "A child mspec-run process printed unexpected output on STDOUT"
- if last_file = last_files[io]
- msg += " while running #{last_file}"
- end
- abort "\n#{msg}: #{reply.inspect}"
- end
-
- unless @files.empty?
- file = @files.shift
- last_files[io] = file
- io.puts file
- end
- }
- end
-
- success = true
- children.each { |child|
- child.puts "QUIT"
- _pid, status = Process.wait2(child.pid)
- success &&= status.success?
- child.close
- }
-
- formatter.aggregate_results(output_files)
- formatter.finish
- success
+ ParallelRunner.new(@files, processes, formatter, argv).run
end
def run