Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

explicit process.exit for serial-mode #128

Open
wants to merge 1 commit into from

3 participants

shivaken Ivo Benner Juan Ignacio Iglesias
shivaken

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

Ivo Benner

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.

Juan Ignacio Iglesias

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

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.

Juan Ignacio Iglesias

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

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.

Juan Ignacio Iglesias

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

'--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.

Juan Ignacio Iglesias

@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
Commits on Sep 3, 2011
  1. shivaken
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 0 deletions.
  1. +2 −0  bin/expresso
2  bin/expresso
View
@@ -750,6 +750,8 @@ function runFiles(files) {
(function next(){
if (files.length) {
runFile(files.shift(), next);
+ } else {
+ process.exit(0);
}
})();
} else {
Something went wrong with that request. Please try again.