Skip to content

Handle fuubar #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions .rubocop_gradual.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
27 changes: 15 additions & 12 deletions lib/turbo_tests/reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions lib/turbo_tests/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]
Expand Down
Loading