Skip to content
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

RSpec incremental summarized output #708

Open
danielwaterworth opened this issue Jun 19, 2019 · 4 comments
Open

RSpec incremental summarized output #708

danielwaterworth opened this issue Jun 19, 2019 · 4 comments

Comments

@danielwaterworth
Copy link

I'm one of the developers working on Discourse and we have recently starting using parallel_tests. I've been tasked with making parallel rspec work more like regular rspec. We'd like to see progress as it happens and then see a single summary at the end (much like as is described in #411).

The way I've chosen to go about doing this is to make each subprocess use a custom rspec formatter that produces a json object for each event (code). The main process then parses these events and does its own reporting (code). See this PR on discourse for more information.

This will work for us, but judging by some of the issues in this tracker (#411, #523, #704), there are other users of this gem that might also benefit from such changes. However, it's quite a substantial departure from the current behavior.

Would you be interested in receiving PRs that add this functionality?

@grosser
Copy link
Owner

grosser commented Jun 19, 2019

I like the current simplicity of "run these commands and display their output", that seems very sturdy and won't break between different frameworks and their versions.

Having an opt-in formatter that produce a more standardized output (that can later be expanded to all test frameworks) and a parser for that seems like a good enhancement though.

The common format already exists with junit output https://github.com/sj26/rspec_junit_formatter + https://github.com/aespinosa/minitest-junit + https://github.com/cucumber/cucumber-ruby/blob/master/lib/cucumber/formatter/junit.rb so ideally reuse that / instruct users what gems to add and add --junit flag to parse the the resulting files (might have to add the --format or so flags since we need to set known output locations, not sure).

@danielwaterworth
Copy link
Author

It looks like we're in slightly different positions here:

Discourse uses one version of one testing framework and we decide when to upgrade it, but parallel_tests supports many versions of many testing frameworks and can't anticipate new versions.

In light of that, I definitely see the benefit of a common test suite format. Any summarizing and displaying becomes test-suite independent and it reduces the amount of test-framework specific code compared to my approach.

However, for our purposes, junit xml is less than ideal because it's not incremental, but it looks like TAP-Y/J might work. There's https://github.com/rubyworks/rspec-ontap and https://github.com/rubyworks/minitap, but cucumber is missing.

@grosser
Copy link
Owner

grosser commented Jun 20, 2019 via email

discoursereviewbot referenced this issue in discourse/discourse Jun 21, 2019
* DEV: Add a new way to run specs in parallel with better output

This commit:

 1. adds a new executable, `bin/interleaved_rspec` which works much like
    `rspec`, but runs the tests in parallel.

 2. adds a rake task, `rake interleaved:spec` which runs the whole test
    suite.

 3. makes autospec use this new wrapper by default. You can disable this
    by running `PARALLEL_SPEC=0 rake autospec`.

It works much like the `parallel_tests` gem (and relies on it), but
makes each subprocess use a machine-readable formatter and parses this
output in order to provide a better overall summary.

(It's called interleaved, because parallel was taken and naming is
hard).

* Make popen3 invocation safer

* Use FileUtils instead of shelling out

* DRY up reporter

* Moved summary logic into Reporter

* s/interleaved/turbo/g

* Move Reporter into its own file

* Moved run into its own class

* Moved Runner into its own file

* Move JsonRowsFormatter under TurboTests

* Join on threads at the end

* Acted on feedback from eviltrout
@danmayer
Copy link

I would be really interested if this gets rolled into parallel_tests, very cool work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants