diff --git a/lib/turbo_tests/reporter.rb b/lib/turbo_tests/reporter.rb index 4996dca..4374af8 100644 --- a/lib/turbo_tests/reporter.rb +++ b/lib/turbo_tests/reporter.rb @@ -4,8 +4,8 @@ module TurboTests class Reporter attr_writer :load_time - def self.from_config(formatter_config, start_time) - reporter = new(start_time) + def self.from_config(formatter_config, start_time, files, parallel_options) + reporter = new(start_time, files, parallel_options) formatter_config.each do |config| name, outputs = config.values_at(:name, :outputs) @@ -23,7 +23,7 @@ def self.from_config(formatter_config, start_time) attr_reader :pending_examples attr_reader :failed_examples - def initialize(start_time) + def initialize(start_time, files, parallel_options) @formatters = [] @pending_examples = [] @failed_examples = [] @@ -32,9 +32,13 @@ def initialize(start_time) @start_time = start_time @load_time = 0 @errors_outside_of_examples_count = 0 + @files = files + @parallel_options = parallel_options end def add(name, outputs) + require "fuubar" if name == "Fuubar" + outputs.each do |output| formatter_class = case name @@ -48,6 +52,13 @@ def add(name, outputs) @formatters << formatter_class.new(output) end + + if name == "Fuubar" + files = ParallelTests::RSpec::Runner.send(:find_tests, @files, @parallel_options) + output = `#{ENV.fetch("BUNDLE_BIN_PATH")} exec rspec --dry-run #{files.join(" ")} | grep 'examples, 0 failures'` + example_count = output.split(" ").first.to_i + delegate_to_formatters(:start, RSpec::Core::Notifications::StartNotification.new(example_count)) + end end def group_started(notification) diff --git a/lib/turbo_tests/runner.rb b/lib/turbo_tests/runner.rb index 51caf4e..ab54184 100644 --- a/lib/turbo_tests/runner.rb +++ b/lib/turbo_tests/runner.rb @@ -10,17 +10,9 @@ class Runner using CoreExtensions def self.run(opts = {}) - files = opts[:files] - formatters = opts[:formatters] - tags = opts[:tags] - parallel_options = opts[:parallel_options] - # SEE: https://bit.ly/2NP87Cz start_time = opts.fetch(:start_time) { Process.clock_gettime(Process::CLOCK_MONOTONIC) } - runtime_log = opts.fetch(:runtime_log, nil) verbose = opts.fetch(:verbose, false) - fail_fast = opts.fetch(:fail_fast, nil) - count = opts.fetch(:count, nil) seed = opts.fetch(:seed) || rand(0xFFFF).to_s seed_used = !opts[:seed].nil? @@ -28,28 +20,22 @@ def self.run(opts = {}) STDERR.puts "VERBOSE" end - reporter = Reporter.from_config(formatters, start_time) - new( - reporter: reporter, - files: files, - tags: tags, - runtime_log: runtime_log, + **opts, + start_time: start_time, verbose: verbose, - fail_fast: fail_fast, - count: count, seed: seed, - seed_used: seed_used, - parallel_options: parallel_options + seed_used: seed_used ).run end - def initialize(opts) - @reporter = opts[:reporter] + def initialize(**opts) + @formatters = opts[:formatters] @files = opts[:files] @tags = opts[:tags] @verbose = opts[:verbose] @fail_fast = opts[:fail_fast] + @start_time = opts[:start_time] @count = opts[:count] @load_time = 0 @load_count = 0 @@ -67,6 +53,8 @@ def initialize(opts) end def run + @reporter = Reporter.from_config(@formatters, @start_time, @files, @parallel_options) + @num_processes = [ ParallelTests.determine_number_of_processes(@count), ParallelTests::RSpec::Runner.tests_with_size(@files, {}).size