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

Add error-exit-code to differentiate from failures #2749

Merged
merged 1 commit into from Aug 14, 2020

Conversation

robotdana
Copy link
Contributor

@robotdana robotdana commented Aug 13, 2020

it can be helpful to know if RSpec fails because of an example or if it
errors out because it couldn't load a spec file, or there was an issue
in the a before(:suite) hook or etc

i've named the setting error-exit-code, and tried to add it to all the
relevant places, but i don't know rspec codebase well so there was some
guessing. in particular i'm not sure what bisect should do.

i have it fall back to the failure-exit-code before defaulting to 1 so
there's no changes if people don't opt in to the setting.

the specific usecase of this is our CI automatically retries failures using
the persistence file, and assumes if they pass on that retry they were
flaky. however, the persistence file isn't written to when there's an
error outside of examples, so this could mean falsely passing builds.

by checking for a different exit code, and then not running the retry we
can avoid this issue.


This PR also includes me trying to make travis builds work. there were gem/ruby version issues with simplecov-html, childprocecss, & rake (these issues were also present in other RSpec projects, so when it tries to build e.g. rspec-expectations it still fails. that's when i gave up trying to make travis work)

@robotdana robotdana force-pushed the error_exit_code branch 7 times, most recently from c6929c6 to a9c50b9 Compare August 13, 2020 06:49
@robotdana
Copy link
Contributor Author

I did have a green build: https://travis-ci.org/github/rspec/rspec-core/builds/717497518

Copy link
Member

@JonRowe JonRowe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to add this, I've suggested some refactoring to how this should work, specifically I don't think config is the right place for introspecting the world (especially with injection, thats a potential confusion I'd like to avoid) like this.

If you could also drop the build changes, or seperate them to another PR that'd be helpful.

features/configuration/failure_exit_code.feature Outdated Show resolved Hide resolved
Gemfile Outdated Show resolved Hide resolved
lib/rspec/core/configuration.rb Outdated Show resolved Hide resolved
lib/rspec/core/configuration.rb Outdated Show resolved Hide resolved
lib/rspec/core/runner.rb Outdated Show resolved Hide resolved
script/rspec_with_simplecov Outdated Show resolved Hide resolved
lib/rspec/core/invocations.rb Outdated Show resolved Hide resolved
lib/rspec/core/runner.rb Outdated Show resolved Hide resolved
@robotdana
Copy link
Contributor Author

the build changes are now in #2750

lib/rspec/core/runner.rb Outdated Show resolved Hide resolved
lib/rspec/core/runner.rb Outdated Show resolved Hide resolved
lib/rspec/core/runner.rb Outdated Show resolved Hide resolved
@JonRowe
Copy link
Member

JonRowe commented Aug 14, 2020

the build changes are now in #2750

Thanks, you can see this PR actually passed without them

it can be helpful to know if RSpec fails because of an example or if it
errors out because it couldn't load a spec file, or there was an issue
in the a before(:suite) hook or etc

i've named the setting error-exit-code, and tried to add it to all the
relevant places, but i don't know rspec codebase well so there was some
guessing. in particular i'm not sure what bisect should do.

i have it fall back to the failure-exit-code before defaulting to 1 so
there's no changes if people don't opt in to the setting.

the specific use of this is our CI automatically retries failures using
the persistence file, and assumes if they pass on that retry they were
flaky. however, the persistence file isn't written to when there's an
error outside of examples, so this could mean falsely passing builds.

by checking for a different exit code, and then not running the retry we
can avoid this issue.
@JonRowe
Copy link
Member

JonRowe commented Aug 14, 2020

@robotdana I'm going to merge this if you're done with it?

@robotdana
Copy link
Contributor Author

yeah thank you :)

@JonRowe JonRowe merged commit b0d0843 into rspec:main Aug 14, 2020
JonRowe added a commit that referenced this pull request Aug 14, 2020
@pirj
Copy link
Member

pirj commented Aug 14, 2020

Thanks, @robotdana !

MatheusRich pushed a commit to MatheusRich/rspec-core that referenced this pull request Oct 30, 2020
Add error-exit-code to differentiate from failures
MatheusRich pushed a commit to MatheusRich/rspec-core that referenced this pull request Oct 30, 2020
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

Successfully merging this pull request may close these issues.

None yet

3 participants