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

Merged
merged 1 commit into from Dec 1, 2016

Projects

None yet

5 participants

@nkabardin
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

@davidtheclark

Nice work @nkabardin! 👍

@nkabardin
Contributor

@davidtheclark thanks!

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

@nkabardin
Contributor

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

@ntwb
Member
ntwb commented Nov 29, 2016

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

@ntwb
Member
ntwb commented Nov 29, 2016 edited

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
Contributor

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

@nkabardin
Contributor

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

@nkabardin
Contributor

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
Contributor

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
Member
ntwb commented Nov 30, 2016 edited

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
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)

@davidtheclark

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 })
@davidtheclark
davidtheclark Dec 1, 2016 Contributor

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

@nkabardin
nkabardin Dec 1, 2016 Contributor

done

@nkabardin nkabardin Handle non-integer exit codes 1 in cli (#2115)
e606bbb
@jeddy3
jeddy3 approved these changes Dec 1, 2016 View changes
+ 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
@evilebottnawi
evilebottnawi Dec 1, 2016 edited Member

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

@nkabardin
nkabardin Dec 1, 2016 Contributor

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

@evilebottnawi
evilebottnawi Dec 1, 2016 Member

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

@nkabardin
nkabardin Dec 1, 2016 Contributor

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

@davidtheclark
Contributor

Thanks again @nkabardin!

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

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 91.891%
Details
@davidtheclark
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 nkabardin:2115-fix-cli-exit-code branch Dec 1, 2016
@nkabardin
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment