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

CLI: fixup shutdown/interrupt code #7019

Closed
wants to merge 1 commit into from
Closed

Conversation

stefanpenner
Copy link
Contributor

@stefanpenner stefanpenner commented May 2, 2017

  • fix tests
  • add regression test

@stefanpenner stefanpenner force-pushed the interrupt-fun branch 5 times, most recently from 1153c20 to 2ca57a8 Compare May 2, 2017 23:47
bmac added a commit to bmac/data that referenced this pull request May 3, 2017
… failing on master

This is a temporary change to unblock Ember Data

See ember-cli/ember-cli#7019 for a more long term fix
bmac added a commit to bmac/data that referenced this pull request May 3, 2017
…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
bmac added a commit to bmac/data that referenced this pull request May 3, 2017
…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
@stefanpenner stefanpenner force-pushed the interrupt-fun branch 4 times, most recently from 939e45d to 20087cb Compare May 3, 2017 01:56
stefanpenner referenced this pull request May 3, 2017
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.
@stefanpenner stefanpenner mentioned this pull request May 3, 2017
11 tasks
@stefanpenner
Copy link
Contributor Author

r? @hjdivad / @rwjblue / @ro0gr

@@ -228,6 +235,31 @@ describe('Unit: CLI', function() {
});
});

describe.only('command crash', function() {
Copy link
Member

Choose a reason for hiding this comment

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

Remove the only

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooo. Will fix

Copy link
Contributor

@hjdivad hjdivad left a 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.

@stefanpenner
Copy link
Contributor Author

Windows CI seems unhappy, re-running. If not I can take a look tonight when i have a windows machine handy.

};

return ember(['custom']).then(function() {
expect(false, 'should have rejected').to.eql(false);
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Copy link
Member

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;

@stefanpenner stefanpenner force-pushed the interrupt-fun branch 4 times, most recently from 93f754f to 7f008fd Compare May 4, 2017 04:10
};

return ember(['custom']).then(function() {
expect(false, 'should have rejected').to.eql(true);
Copy link
Contributor Author

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.

bmac added a commit to emberjs/data that referenced this pull request May 5, 2017
…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)
bmac added a commit to emberjs/data that referenced this pull request May 5, 2017
…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)
@ro0gr
Copy link
Contributor

ro0gr commented May 15, 2017

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:

√ ember new foo, test, SIGINT exits with error and clears tmp/ (145694ms)

  1. "after each" hook for "ember new foo, test, SIGINT exits with error and clears tmp/"

1 passing (4m)
1 failing

  1. Acceptance: smoke-test "after each" hook for "ember new foo, test, SIGINT exits with error and clears tmp/":
    AssertionError: expected "C:\Users\kudgo\workspace\ember-cli\tmp\some_cool_app_clone-KeX18ufj.tmp" to not exist

Literally afterEach is unable to delete temporary application made for test. The reason for this is that testem doesn't kill phantomjs process anymore. This process locks test application directory.

testem.log - before this pr

info Test'em starting..
info Seeking for config file...
info Starting ci
info Starting server
info Waiting for tests.
info Start triggered test run.
info Running tests...
info Tests running.
info spawning: phantomjs - [ 'C:\Users\kudgo\workspace\ember-cli\node_modules\testem\assets\phantom.js',
'http://localhost:7357/5383/tests/index.html?hidepassed' ]
info New client connected: PhantomJS 2.1 5383
info tryAttach PhantomJS 2.1 5383
info received SIGINT signal
info Closing browser PhantomJS.
WARN PhantomJS closed 1
info Process PhantomJS terminated. 1 null

testem.log - this pr

info Test'em starting..
info Seeking for config file...
info Starting ci
info Starting server
info Waiting for tests.
info Start triggered test run.
info Running tests...
info Tests running.
info spawning: phantomjs - [ 'C:\Users\kudgo\workspace\ember-cli\node_modules\testem\assets\phantom.js',
'http://localhost:7357/5096/tests/index.html?hidepassed' ]
info New client connected: PhantomJS 2.1 5096
info tryAttach PhantomJS 2.1 5096
info

In the second log we miss received SIGINT signal entry which causes the problem.

I'm in process of investigation. Any ideas would be awesome.

@ro0gr
Copy link
Contributor

ro0gr commented May 15, 2017

It's not just a test setup issue. It also reproducible by manual verification

@homu
Copy link
Contributor

homu commented May 17, 2017

☔ The latest upstream changes (presumably #7048) made this pull request unmergeable. Please resolve the merge conflicts.

@ro0gr
Copy link
Contributor

ro0gr commented May 22, 2017

The bad news is that it breaks testem integration on windows.

After some testing it turned out that it breaks only with phantomjs. Chrome launcher is disposed properly.
Seems like some kind of timing issue. Wrapping of interruption handler in timeout "fixes" the problem:

        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 ember-cli@2.12 the problem persist there. The reason why this issue didn't appear earlier in tests is that we didn't have smoke test for ember test interruption.

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();
Copy link
Contributor

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?

@ro0gr ro0gr mentioned this pull request May 28, 2017
@ro0gr ro0gr mentioned this pull request Jun 7, 2017
7 tasks
@ro0gr
Copy link
Contributor

ro0gr commented Jun 29, 2017

@stefanpenner I believe now with headless chrome this should pass under appveyor

@kellyselden
Copy link
Member

@ro0gr Rebased on master.

@ro0gr
Copy link
Contributor

ro0gr commented Jul 13, 2017

@kellyselden great!

There is one failing test which breaks here .

I think it should be re-written to match updated will-interrupt-process api.

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.

@stefanpenner
Copy link
Contributor Author

@ro0gr its merged!

@Turbo87
Copy link
Member

Turbo87 commented May 17, 2018

closing due to inactivity and conflicts

@Turbo87 Turbo87 closed this May 17, 2018
@rwjblue rwjblue deleted the interrupt-fun branch December 19, 2019 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants