-
Notifications
You must be signed in to change notification settings - Fork 280
Return correct exit code when server fails to start #851
Conversation
9b4dd01
to
fdb9118
Compare
fdb9118
to
3576ec9
Compare
@honzajavorek Fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the changes 👍 Great job. I wonder what your replies to my comments would be, otherwise I'd approve this.
src/dredd-command.coffee
Outdated
@serverProcess.on 'error', (error) => | ||
logger.error('Command to start backend server process failed, exiting Dredd', error) | ||
@_processExit(2) | ||
@serverProcess.on 'spawnerror', (err) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized we probably want to do this in case of any kind of error happening to the backend server child process. If the process errors, Dredd cannot ensure the testing will make sense, and it should stop testing and terminate. So I propose we actually keep @serverProcess.on 'error'
here. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no problem with that, we can differentiate between different type of runtime errors in single error handler hub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reflected in ab90347.
@@ -90,6 +90,26 @@ describe 'CLI - Server Process', -> | |||
it 'should exit with status 0', -> | |||
assert.equal dreddCommandInfo.exitStatus, 0 | |||
|
|||
describe 'When it fails to start', -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized there's one more side to the problem: The process starts, but Dredd isn't able to connect to it using HTTP. Looking into coverage, this scenario seems to be untested:
transaction-runner.coffee
I hope it would still work as expected (Dredd fails all tests and it ends with exit code 1), but it would be awesome if we had a test for that as well. What do you think?
It should be fairly easy to test, with the same approach, just spawning an existing script, which hangs the same way as server would do (endless setTimeout
loop?), but which doesn't handle HTTP in any way. Maybe there's even already a script like that in test/fixtures
, I haven't take a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, I'll have a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My attempt is in #862. If the section screenshoted above won't get green, then the test is useless and my PR should get closed.
ab90347
to
6e6c23c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
🚀 Why this change?
This PR fixes the issue with wrong CLI exit code when running Dredd with incorrect argument to
--server
command (reported in #818).📝 Related issues and Pull Requests
Closes #838
✅ What didn't I forget?
npm run lint