Sha256: 12425b5bd2b559dd304cecdb2afbf12532d4f78fc8360fa78d7fb759099a39f0
Contents?: true
Size: 1.73 KB
Versions: 16
Compression:
Stored size: 1.73 KB
Contents
# frozen_string_literal: true module Jive class BatchRunner attr_reader :runner, :stdout def initialize(runner: Runner.new, stdout: $stdout) @runner = runner @stdout = stdout end def run(tasks) stream_output_for(runner, tasks) stdout.puts "===================================================" print_result_for(runner) end private def stream_output_for(runner, tasks) runner.run(tasks) do |command, &run| stdout.puts stdout.puts "$ #{command.join(" ")}" result = run.call stdout.print result.stdout stdout.print result.stderr stdout.puts "==> Finished in #{result.duration} seconds" stdout.puts end end def print_result_for(runner) if runner.all_success_and_clean? stdout.puts "Passed successfully." 0 elsif runner.all_success? stdout.puts "Passed successfully, but we have warnings:" stdout.puts emit_warnings_for(runner) 2 else stdout.puts "Something failed:" emit_warnings_for(runner) emit_errors_for(runner) 1 end end def emit_warnings_for(runner) runner.warned_results.each do |result| stdout.puts stdout.puts "**** #{result.command.join(" ")} had the following warning(s):" stdout.puts stdout.puts result.stderr stdout.puts end end def emit_errors_for(runner) runner.failed_results.each do |result| stdout.puts stdout.puts "**** #{result.command.join(" ")} failed with the following error(s):" stdout.puts stdout.puts result.stdout stdout.puts result.stderr stdout.puts end end end end
Version data entries
16 entries across 16 versions & 1 rubygems