Skip to content

explicit process.exit for serial-mode#128

Open
shivaken wants to merge 1 commit into
visionmedia:masterfrom
shivaken:67b48694469858dcc3d4ed74ebc4ac3a55b2d80d
Open

explicit process.exit for serial-mode#128
shivaken wants to merge 1 commit into
visionmedia:masterfrom
shivaken:67b48694469858dcc3d4ed74ebc4ac3a55b2d80d

Conversation

@shivaken

@shivaken shivaken commented Sep 3, 2011

Copy link
Copy Markdown

With mongoose, expresso doesn't exit. Make expresso exit after serial-mode test execution.

@skython

skython commented Sep 10, 2011

Copy link
Copy Markdown

I'm having the same problem with the node-postgres module.
It's even worse there since closing the connection pool there doesn't seem to have any effect.

Thx for the commit, applied it already to my local expresso.

@ignacioiglesias

Copy link
Copy Markdown

Same problem here when testing with socket.io. I came up with a fix that looks just like the one from shivaken, however, it doesn't solve the problem because when process.exit is called, Expresso outputs:
Failure: Only 1 of 3 suites have been started

@shivaken

shivaken commented Nov 1, 2011

Copy link
Copy Markdown
Author

ignacioiglesias
Dose your test methods accept args (callback)? In serial mode, test method has to call callback in the end.
If they are not defined as no callback function, expresso executes test methods async.

@ignacioiglesias

Copy link
Copy Markdown

Hey, thanks for your answer.

Yes. My tests are taking the callback and calling it when the test is done; I'm using --serial because I'm testing a socket.io so the first argument of my test functions should be that callback, shouldn't it?

I finally I fixed it wrapping the process.exit call into process.nextTick(function() { process.exit(); });.

Here's the pull request: #148 feel free to give it a try.

Also, not sure if useful, I'm using Expresso 0.9.2 in Lion

@shivaken

shivaken commented Nov 1, 2011

Copy link
Copy Markdown
Author

Thank you Ignacioiglesias.

I don't understand why you have to wrap 'process.exit' by 'process.nextTick'.

'Failure: Only 1 of 3 suites have been started'
It seems that you run 3 test suites(js file?)
How does it go, when you execute test one by one?

I'm using latest express + my patch in node-0.4.12, Snow Leopard.

@ignacioiglesias

Copy link
Copy Markdown

It wasn't clear to me why wrapping process.exit in a timeout or process.nextTick helped until I found this answer in stackoverflow.

To answer your question about executing tests one by one, I still need to use --serial because there are more than one test per file and every test creates a socket.io server to talk to.

I wonder if this has to do with the OS.

@shivaken

shivaken commented Nov 1, 2011

Copy link
Copy Markdown
Author

'--serial' will execute test sync not only test suite. so If your test suite has two or more tests, you have to use with '--serial'.

for example, In my test, server is created only one time in initializing code that was separated from test code and just include via 'require' in test suite code.

'server = require('app').server'

then use server in test method.

@ignacioiglesias

Copy link
Copy Markdown

@shivaken: I think I didn't express myself correctly; Given the nature of my tests, I am always using --serial.

Regarding your suggestion about the usage of server = require('app').server, it's a great thing to do unless you want to create and destroy servers (and that is something I want to do ^_^).

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.

3 participants