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

workaround for windows to ensure console.log is always flushed before pr... #111

Closed
wants to merge 1 commit into from

Conversation

malonecj
Copy link

@malonecj malonecj commented Aug 6, 2014

...ocess.exit

This is a potential solution for #110

I don't have much experience with Node yet so I might be missing something here, but it at least fixed my problem and am now seeing all test results logged to console.

@@ -321,7 +321,9 @@ function _main(onComplete) {

if (argv.help) {
optimist.showHelp();
process.exit(0);
process.on('exit', function(){
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, hadn't heard of this before...but seems to be a KP: https://www.npmjs.org/package/exit

One thing we need to be sure of on these changes is that execution doesn't continue after exiting (which was part of the intent of those exits before). So we either need to refactor the scripts so they can return early after setting up this listener, or find a way to make sure that the remaining code doesn't continue to execute if we hit this branch in the code path.

@tcoopman
Copy link

tcoopman commented Oct 1, 2014

What's the status of this?

@jeffmo
Copy link
Contributor

jeffmo commented Oct 1, 2014

I think we're just waiting on the update to the PR per the inline comment.
@malonecj: Did you want to finish this out?

@malonecj
Copy link
Author

Sorry, have not had a chance to use Jest again since submitting this. I should hopefully get some time to look into this in the next week or so

@ForbesLindesay
Copy link
Contributor

I'm not sure the problem with tests "continuing to execute" makes sense. If all jest tests are synchronous, then the initial thrown exception should terminate the tests anyway, so there shouldn't be any need to worry about that?

@jeffmo If you want me to re-write this to use the 'exit' module I'm happy to make that change.

@jeffmo
Copy link
Contributor

jeffmo commented Dec 2, 2014

In the code change I commented on, we want the jest CLI to stop then-and-there if --help was passed
(i.e. not print the help and go on to continue executing whatever command it might have if --help weren't specified)

@jeffmo
Copy link
Contributor

jeffmo commented Dec 2, 2014

Also I'm not quite sure what you meant by tests executing synchronously -- but test files themselves run asynchronously, so a failing test would not stop the Jest cli in it's tracks

@mkristo
Copy link

mkristo commented Dec 2, 2014

@jeffmo I just tried using the proposed 'exit' module instead of process.exit, and it seems to work just as intended. Both with and without the --help directive. I might not understand the problem though.

@ForbesLindesay
Copy link
Contributor

@jeffmo Thanks, I think I understand now. I had assumed you meant that comment to apply to all the process.exit calls, but it makes far more sense for just the --help case. I think it would be ok to just use the original process.exit code in the --help case, since at that point stdio is still in blocking mode. We would only need to use the exit module for the other cases where stdio may have been put into non-blocking mode.

@jquense
Copy link
Contributor

jquense commented Jan 1, 2015

any word on when this might hit? I'd be happy to help get it done. Without this Jest doesn't provide any feedback on windows, rendering it useless as a testing tool

@jeffmo
Copy link
Contributor

jeffmo commented Jan 23, 2015

I am happy to take this, but it's in a place where it needs some refactoring (and bin/jest.js has changed since this was written). I would go in and just finish this up myself (seems fairly straightforward), but I don't have a working Windows machine to try to port this to the latest code...so I wouldn't feel comfortable doing so without being able to verify and test.

Could either @malonecj or someone else who's running on windows finish this out and confirm that it fixes things? I'm happy to take it if we can get the stop-execution problem worked out (the thing I commented inline)

@jquense
Copy link
Contributor

jquense commented Jan 23, 2015

@jeffmo I threw something together let me know if its enough!

@jeffmo
Copy link
Contributor

jeffmo commented Jan 23, 2015

Awesome, thanks a ton @jquense !

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants