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

fix: only set error codes when they are non zero #7363

Merged
merged 7 commits into from
Nov 21, 2018

Conversation

jcreamer898
Copy link
Contributor

@jcreamer898 jcreamer898 commented Nov 13, 2018

Summary

I'm working on an internal CLI that runs jest, eslint, and sasslint all in one single process for our frontend team to run from their package.json's

Aka something like, "test": "cli test".

The code process.on('exit', () => (process.exitCode = code)); adds a listener that is overriding the exit codes we're setting so that when jest is successful, and eslint or sasslint fail, I can't exit with a failing code.

Therefore our CI's are reporting as passed even though the linting fails.

It seems as though there's no reason to actually set the error code at all unless it's non-zero?

Let me know what the thoughts here are. I can come back in and add more, add some additional tests, etc if this looks like an ok change.

Thanks!

Test plan

Pretty much just make sure that jest still reports a non-zero exit code with a failing test.

I'm working on an internal CLI that runs jest, eslint, and sasslint all in one single process for our frontend team to run from their `package.json`'s

Aka something like, `"test": "cli test"`.

The code `process.on('exit', () => (process.exitCode = code));` adds a listener that is overriding the exit codes we're setting so that when jest is successful, and eslint or sasslint fail, I can't exit with a failing code.

Therefore our CI's are reporting as passed even though the linting fails.

It seems as though there's no reason to actually set the error code at all unless it's non-zero?

Let me know what the thoughts here are. I can come back in and add more, add some additional tests, etc if this looks like an ok change.

Thanks!
@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Needs a changelog entry

packages/jest-cli/src/cli/index.js Outdated Show resolved Hide resolved
@SimenB SimenB requested a review from mjesun November 13, 2018 23:46
@jcreamer898
Copy link
Contributor Author

Changelog and code both updated.

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

CHANGELOG.md Outdated Show resolved Hide resolved
@jcreamer898
Copy link
Contributor Author

So, @SimenB that lint-and-typecheck step keeps failing?

CHANGELOG.md Outdated Show resolved Hide resolved
@rickhanlonii
Copy link
Member

Sorry for reviewing this after you fixed the lint, but I left a couple questions

@jcreamer898
Copy link
Contributor Author

Haha @rickhanlonii no worries, I'd rather get it right.

@codecov-io
Copy link

Codecov Report

Merging #7363 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #7363   +/-   ##
=======================================
  Coverage   66.72%   66.72%           
=======================================
  Files         241      241           
  Lines        9356     9356           
  Branches        6        6           
=======================================
  Hits         6243     6243           
  Misses       3110     3110           
  Partials        3        3

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b7c75d...8ed3dae. Read the comment docs.

@jcreamer898
Copy link
Contributor Author

Anything else y'all need from me to mergy merge?

@SimenB
Copy link
Member

SimenB commented Nov 20, 2018

@rickhanlonii mind taking a last look? 🙂

@rickhanlonii
Copy link
Member

Looks great, thanks @jcreamer898 and welcome to Jest!

@rickhanlonii rickhanlonii merged commit b3c10cb into jestjs:master Nov 21, 2018
@jcreamer898
Copy link
Contributor Author

Thanks!!

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants