Skip to content

chore(build): fix karma not exiting properly #1741

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

Merged
merged 1 commit into from
Nov 11, 2016

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Nov 5, 2016

  • Fixes the Karma tasks not exiting properly. This is an issue, because doing a keyboard interrupt doesn't stop the Gulp watchers that are going on in the background.
  • Increase the time that Karma waits before starting to run tests. This should help mitigate the multiple reloads when running unit tests locally.

Related to #1681.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 5, 2016
@crisbeto crisbeto force-pushed the 1681/karma-not-exiting branch from 01943fe to 50bd305 Compare November 5, 2016 15:10
@jelbourn
Copy link
Member

jelbourn commented Nov 8, 2016

R: @hansl

@@ -59,6 +59,7 @@ export function config(config) {
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
autoWatchBatchDelay: 1000,
Copy link
Contributor

Choose a reason for hiding this comment

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

1000 might be too slow. 500?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ideally, it would debounce the changes, but since this is only the timeout from the first change to when it reloads, it should be fine. This was the "ideal" one that didn't feel slow and caused the least refreshing.

new karma.Server({
configFile: path.join(PROJECT_ROOT, 'test/karma.conf.js')
}, done).start();
}).start();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably not the right fix. By default, Karma uses process.exit as the callback. We definitely want to exit Gulp gracefully.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can switch it to:

() => {
  done();
  process.exit();
}

I didn't include it initially, because it seemed redundant since process.exit kills the process anyway (which includes Gulp).

@crisbeto crisbeto force-pushed the 1681/karma-not-exiting branch 2 times, most recently from 7c7c37b to efa4188 Compare November 8, 2016 20:51
@crisbeto
Copy link
Member Author

crisbeto commented Nov 8, 2016

Updated to both exit Gulp and the process, as well as reduced the autoWatchBatchDelay @hansl.

@hansl
Copy link
Contributor

hansl commented Nov 8, 2016

@crisbeto: That's the thing; we don't want to exit the process. We want Gulp to finish the tasks gracefully. Isn't there a better way to kill the watch tasks?

@crisbeto
Copy link
Member Author

crisbeto commented Nov 8, 2016

I'm not sure interrupting a task while it's running is really an issue here, because Karma always runs after all of the build steps. I don't know of a better way to kill it (considering that Karma's default is process.exit).

Also we should keep in mind that this is mainly for local development.

@@ -51,7 +51,10 @@ gulp.task(':test:deps:inline', sequenceTask(':test:deps', ':inline-resources'));
gulp.task('test', [':test:watch'], (done: () => void) => {
new karma.Server({
configFile: path.join(PROJECT_ROOT, 'test/karma.conf.js')
}, done).start();
}, (exitCode: number) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay you can remove the handler. Seems like there's no way to terminate a watch task... which sucks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

* Fixes the Karma tasks not exiting properly. This is an issue, because doing a keyboard interrupt doesn't stop the Gulp watchers that are going on in the background.
* Increase the time that Karma waits before starting to run tests. This should help mitigate the multiple reloads when running unit tests locally.

Related to angular#1681.
@crisbeto crisbeto force-pushed the 1681/karma-not-exiting branch from efa4188 to 87f748a Compare November 8, 2016 22:11
@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Nov 11, 2016
@jelbourn jelbourn merged commit 77701cc into angular:master Nov 11, 2016
jelbourn added a commit to jelbourn/components that referenced this pull request Nov 11, 2016
jelbourn added a commit that referenced this pull request Nov 12, 2016
* fix: unbreak unit tests

* Revert "chore(build): fix karma not exiting properly (#1741)"

This reverts commit 77701cc.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants