diff --git a/.rubocop_gradual.lock b/.rubocop_gradual.lock index 4b2c047..7d421b0 100644 --- a/.rubocop_gradual.lock +++ b/.rubocop_gradual.lock @@ -22,17 +22,14 @@ [50, 5, 269, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 4255608859], [71, 5, 614, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 574527918] ], - "lib/turbo_tests/reporter.rb:1386902608": [ - [7, 5, 400, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 2092085575] - ], - "lib/turbo_tests/runner.rb:2125673792": [ + "lib/turbo_tests/runner.rb:3852406545": [ [13, 5, 271, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 21989008], - [20, 5, 1311, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1925027850], - [241, 11, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361], - [260, 47, 6, "Style/GlobalStdStream: Use `$stderr` instead of `STDERR`.", 3356712163], - [262, 21, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361], - [271, 7, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361], - [331, 9, 6, "Style/GlobalStdStream: Use `$stdout` instead of `STDOUT`.", 3356722952] + [20, 5, 1400, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1925027850], + [245, 11, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361], + [264, 47, 6, "Style/GlobalStdStream: Use `$stderr` instead of `STDERR`.", 3356712163], + [266, 21, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361], + [275, 7, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361], + [335, 9, 6, "Style/GlobalStdStream: Use `$stdout` instead of `STDOUT`.", 3356722952] ], "spec/cli_spec.rb:3990998076": [ [1, 1, 30, "RSpec/SpecFilePathFormat: Spec path should end with `turbo_tests/cli*_spec.rb`.", 965721356], diff --git a/README.md b/README.md index f0de0c3..c23b7c2 100644 --- a/README.md +++ b/README.md @@ -109,12 +109,18 @@ Options: --print_failed_group Prints group that had failures in it ``` -To pass any options supported by paralell_tests, use `--` : +To pass any options supported by paralell_tests, use `--`: ```bash bundle exec turbo_tests -n 4 -- --only-group 1 --pattern spec/system ``` +`turbo_tests` supports custom formatter such as Fuubar, but you might need to require it: + +```bash +bundle exec turbo_tests -r fuubar -f Fuubar spec/whatever +``` + ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. diff --git a/lib/turbo_tests/reporter.rb b/lib/turbo_tests/reporter.rb index 472e510..acd2f76 100644 --- a/lib/turbo_tests/reporter.rb +++ b/lib/turbo_tests/reporter.rb @@ -3,26 +3,27 @@ module TurboTests class Reporter attr_writer :load_time + attr_reader :pending_examples, :failed_examples + + class << self + def from_config(formatter_config, start_time, seed, seed_used, files, parallel_options) + reporter = new(start_time, seed, seed_used, files, parallel_options) - def self.from_config(formatter_config, start_time, seed, seed_used) - reporter = new(start_time, seed, seed_used) + formatter_config.each do |config| + name, outputs = config.values_at(:name, :outputs) - formatter_config.each do |config| - name, outputs = config.values_at(:name, :outputs) + outputs.map! do |filename| + (filename == "-") ? $stdout : File.open(filename, "w") + end - outputs.map! do |filename| - (filename == "-") ? $stdout : File.open(filename, "w") + reporter.add(name, outputs) end - reporter.add(name, outputs) + reporter end - - reporter end - attr_reader :pending_examples, :failed_examples - - def initialize(start_time, seed, seed_used) + def initialize(start_time, seed, seed_used, files, parallel_options) @formatters = [] @pending_examples = [] @failed_examples = [] @@ -33,6 +34,8 @@ def initialize(start_time, seed, seed_used) @seed_used = seed_used @load_time = 0 @errors_outside_of_examples_count = 0 + @files = files + @parallel_options = parallel_options end def add(name, outputs) diff --git a/lib/turbo_tests/runner.rb b/lib/turbo_tests/runner.rb index dce9a6d..1bb7117 100644 --- a/lib/turbo_tests/runner.rb +++ b/lib/turbo_tests/runner.rb @@ -43,10 +43,12 @@ def self.run(opts = {}) warn("VERBOSE") if verbose - reporter = Reporter.from_config(formatters, start_time, seed, seed_used) + reporter = Reporter.from_config(formatters, start_time, seed, seed_used, files, parallel_options) new( reporter: reporter, + formatters: formatters, + start_time: start_time, files: files, tags: tags, runtime_log: runtime_log, @@ -62,12 +64,14 @@ def self.run(opts = {}) ).run end - def initialize(opts) + def initialize(**opts) + @formatters = opts[:formatters] @reporter = opts[:reporter] @files = opts[:files] @tags = opts[:tags] @verbose = opts[:verbose] @fail_fast = opts[:fail_fast] + @start_time = opts[:start_time] @count = opts[:count] @seed = opts[:seed] @seed_used = opts[:seed_used]