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

Handle non-integer error codes as exit code 1 (#2115) #2140

Merged
merged 1 commit into from
Dec 1, 2016

Conversation

nkabardin
Copy link
Contributor

Fixes #2115

When there is an error in require() in configuration file, cli gets an error code which is not actually integer, so passing it to process.exit is not a good idea.

Now value is getting checked if it's a number or not, and if it's not a number, it's replaced with plain 1.

System test added that runs cli in ensures that exit code != 0

Copy link
Contributor

@davidtheclark davidtheclark left a comment

Choose a reason for hiding this comment

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

Nice work @nkabardin! 👍

@nkabardin
Copy link
Contributor Author

@davidtheclark thanks!

something is frozen on ci though. Can't understand what's happening.

@nkabardin
Copy link
Contributor Author

Checked log on Travis, and there might be issues with running this system test on jenkins — any ideas what's happening there?

@ntwb
Copy link
Member

ntwb commented Nov 29, 2016

@nkabardin I've restarted the CI tests so lets see what happens...

@ntwb
Copy link
Member

ntwb commented Nov 29, 2016

Coveralls is failing in both 5569.1 and 5569.2 jobs even though #5569.1 is reporting as passed and #5569.2 is failing with a Jest test timing out.

@nkabardin
Copy link
Contributor Author

So I guess it's something related to child_process.spawn, are there any CI-related limitations for that?

@nkabardin
Copy link
Contributor Author

Playing around with error logging in system test, let's see what CI will tell us...

@nkabardin nkabardin force-pushed the 2115-fix-cli-exit-code branch 2 times, most recently from 2d5400b to b05bef1 Compare November 29, 2016 11:18
@nkabardin
Copy link
Contributor Author

did several attempts trying to log out the problems with running stuff, added three console.log to test, and didn't catch the problem, nothing logged.

Any ideas?

@nkabardin nkabardin force-pushed the 2115-fix-cli-exit-code branch 2 times, most recently from efae32d to 02afd14 Compare November 30, 2016 09:28
@nkabardin
Copy link
Contributor Author

Rebased branch over current master (so, support babel drop and no need to use babel-node to run cli) and also and removed all debug stuff and it's currently ready and well tested, and surprisingly issues on CI are also solved, so we got green build there, so yay!

@ntwb
Copy link
Member

ntwb commented Nov 30, 2016

LGTM, though let's get another review from @davidtheclark 👍

Edit: Coveralls coverage is pretty volatile at the moment with the "drop babel" changes, we can redress any coverage issues in follow up PRs

@ntwb
Copy link
Member

ntwb commented Dec 1, 2016

Coverage tests were failing if less than 95%, I've dropped that value to 90%

So ignore the Coveralls failure here in this PR (I couldn't find a way to restart the job)

Copy link
Contributor

@davidtheclark davidtheclark left a comment

Choose a reason for hiding this comment

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

One comment, then let's merge.

const localPath = path.resolve(__dirname)
const cliPath = path.join(localPath, "../../lib/cli.js")

const cliProcess = spawn("node", [ cliPath, `${localPath}/*.css` ], { cwd: localPath })
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add an 'error' listener to this process?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

const cliProcess = spawn("node", [ cliPath, `${localPath}/*.css` ], { cwd: localPath })

cliProcess.on("error", function (error) {
console.log("error running cli:", error) // eslint-disable-line no-console
Copy link
Member

Choose a reason for hiding this comment

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

I think we should have failed test if have error in error event

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it fails anyway if there is an error, it just added logging for that.
Couldn't reproduce a case when it didn't fail on error

Copy link
Member

Choose a reason for hiding this comment

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

@nkabardin we can use mock for reproduce error, we got non zero code (thoretically 😄 ) and test failed, lgtm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't get it, current code looks good to you, or it will look good to you when some mocking will be added? :)

Copy link
Member

Choose a reason for hiding this comment

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

@nkabardin no, all ok

@davidtheclark
Copy link
Contributor

Thanks again @nkabardin!

@davidtheclark davidtheclark merged commit 987b800 into stylelint:master Dec 1, 2016
@davidtheclark
Copy link
Contributor

Changelog entry

  • Fixed: bug where some Node errors in special cases did not cause the CLI to exit with a non-zero code (#2140)

@nkabardin nkabardin deleted the 2115-fix-cli-exit-code branch December 1, 2016 14:58
@nkabardin
Copy link
Contributor Author

@davidtheclark glad I was able to help the project! thanks for stylelint ❤️

sergesemashko pushed a commit to sergesemashko/stylelint that referenced this pull request Mar 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants