-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
CLI: fixup shutdown/interrupt code #7019
Conversation
stefanpenner
commented
May 2, 2017
•
edited
Loading
edited
- fix tests
- add regression test
1153c20
to
2ca57a8
Compare
… failing on master This is a temporary change to unblock Ember Data See ember-cli/ember-cli#7019 for a more long term fix
…er-cli and is failing on master This is a temporary change to unblock Ember Data See ember-cli/ember-cli#7019 for a more long term fix
…er-cli and is failing on master This is a temporary change to unblock Ember Data See ember-cli/ember-cli#7019 for a more long term fix
939e45d
to
20087cb
Compare
Previously the command's run promise would not resolve, and subsequent then handlers responsible for producing instrumentation would never run. Cleanup occurred due to capture-exit. Now our exit handler not only cleans up, but also finishes the run promise chain.
tests/unit/cli/cli-test.js
Outdated
@@ -228,6 +235,31 @@ describe('Unit: CLI', function() { | |||
}); | |||
}); | |||
|
|||
describe.only('command crash', function() { |
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.
Remove the only
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.
Ooo. Will fix
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.
LGTM.
My understanding of how interrupt handlers were executed was wrong.
Windows CI seems unhappy, re-running. If not I can take a look tonight when i have a windows machine handy. |
tests/unit/cli/cli-test.js
Outdated
}; | ||
|
||
return ember(['custom']).then(function() { | ||
expect(false, 'should have rejected').to.eql(false); |
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.
Shouldn't one of these false be a true? Seems like this line will always pass if a promise isn't rejected.
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.
👍
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.
actually we should use https://github.com/domenic/chai-as-promised for tests like that. e.g.
return expect(ember(['custom'])).to.be.rejected;
93f754f
to
7f008fd
Compare
tests/unit/cli/cli-test.js
Outdated
}; | ||
|
||
return ember(['custom']).then(function() { | ||
expect(false, 'should have rejected').to.eql(true); |
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.
switch to chai-as-promised.
7f008fd
to
03d2681
Compare
…er-cli and is failing on master This is a temporary change to unblock Ember Data See ember-cli/ember-cli#7019 for a more long term fix (cherry picked from commit ef68161)
…er-cli and is failing on master This is a temporary change to unblock Ember Data See ember-cli/ember-cli#7019 for a more long term fix (cherry picked from commit ef68161)
I've tested this pr against several known issues:
The good news is that these issues are addressed. The bad news is that it breaks testem integration on windows. I've noticed it in "ember new foo, test, SIGINT exits with error and clears tmp/" test failure. The test on itself passes but afterEach hook fails with the following message:
Literally testem.log - before this pr
testem.log - this pr
In the second log we miss I'm in process of investigation. Any ideas would be awesome. |
It's not just a test setup issue. It also reproducible by manual verification |
☔ The latest upstream changes (presumably #7048) made this pull request unmergeable. Please resolve the merge conflicts. |
After some testing it turned out that it breaks only with removeInterruptionHandler = onProcessInterrupt.addHandler(() => {
return new RSVP.Promise(function(resolve) {
setTimeout(() => {
command.onInterrupt();
resolve();
}, 1000);
}); But it seems like a bad solution. I've checked how does "ctrl+c" work against This pr looks good for me but if we merge most likely it will break windows CI. |
}) | ||
.catch(this.logError.bind(this)); | ||
}).finally(() => { | ||
onProcessInterrupt.teardown(); |
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.
What is the reason for additional teardown
here? https://github.com/ember-cli/ember-cli/pull/7019/files#diff-16a41bfbe414387d773df099f941217eR162 should do all the necessary cleanup?
@stefanpenner I believe now with headless chrome this should pass under appveyor |
03d2681
to
7274291
Compare
@ro0gr Rebased on master. |
@kellyselden great! There is one failing test which breaks here . I think it should be re-written to match updated Before: // ...
removewillInterruptProcess.addHandler(cb);
td.verify(process.stdin.setRawMode(true));
willInterruptProcess.removeHandler(cb);
td.verify(process.stdin.setRawMode(false));
td.verify(process.stdin.setRawMode(), {
ignoreExtraArgs: true,
times: 2,
}); After: // ...
let removeHandler = willInterruptProcess.addHandler(cb); // `addHandler` now yields `removeHandler`
td.verify(process.stdin.setRawMode(true));
removeHandler(cb);
td.verify(process.stdin.setRawMode(false));
td.verify(process.stdin.setRawMode(), {
ignoreExtraArgs: true,
times: 2,
}); I believe this should work. Saying the truth I find this test fragile. We could test it much more better if merge #7086 first. |
@ro0gr its merged! |
closing due to inactivity and conflicts |