From bd382d306de7b41707c8b52718afa9af7e9a24bf Mon Sep 17 00:00:00 2001 From: James Nylen Date: Fri, 26 Dec 2014 15:19:46 -0600 Subject: [PATCH] Fix errors generating coverage reports. server.close() is async, so treat it as such: http://nodejs.org/api/net.html#net_server_close_callback This doesn't seem to matter when test files are run in separate processes using `npm test`, but it does when they are run in the same process for the coverage report. --- tests/test-cookies.js | 5 +++-- tests/test-follow-all-303.js | 5 +++-- tests/test-follow-all.js | 5 +++-- tests/test-form-data.js | 5 +++-- tests/test-form-urlencoded.js | 9 +++++---- tests/test-form.js | 5 +++-- tests/test-gzip.js | 5 +++-- tests/test-hawk.js | 5 +++-- tests/test-http-signature.js | 5 +++-- tests/test-httpModule.js | 8 +++++--- tests/test-multipart.js | 5 +++-- tests/test-onelineproxy.js | 5 +++-- tests/test-rfc3986.js | 5 +++-- 13 files changed, 43 insertions(+), 29 deletions(-) diff --git a/tests/test-cookies.js b/tests/test-cookies.js index 0d631bf20..cf8de5cf9 100644 --- a/tests/test-cookies.js +++ b/tests/test-cookies.js @@ -91,6 +91,7 @@ tape('custom store', function(t) { }) tape('cleanup', function(t) { - server.close() - t.end() + server.close(function() { + t.end() + }) }) diff --git a/tests/test-follow-all-303.js b/tests/test-follow-all-303.js index ff7d0f22f..5e73db258 100644 --- a/tests/test-follow-all-303.js +++ b/tests/test-follow-all-303.js @@ -38,6 +38,7 @@ tape('followAllRedirects with 303', function(t) { }) tape('cleanup', function(t) { - server.close() - t.end() + server.close(function() { + t.end() + }) }) diff --git a/tests/test-follow-all.js b/tests/test-follow-all.js index a22cdbfb7..d6e00d064 100644 --- a/tests/test-follow-all.js +++ b/tests/test-follow-all.js @@ -50,6 +50,7 @@ tape('followAllRedirects', function(t) { }) tape('cleanup', function(t) { - server.close() - t.end() + server.close(function() { + t.end() + }) }) diff --git a/tests/test-form-data.js b/tests/test-form-data.js index 38fa70999..16bf8934d 100644 --- a/tests/test-form-data.js +++ b/tests/test-form-data.js @@ -97,8 +97,9 @@ function runTest(t, json) { t.equal(err, null) t.equal(res.statusCode, 200) t.deepEqual(body, json ? {status: 'done'} : 'done') - server.close() - t.end() + server.close(function() { + t.end() + }) }) }) diff --git a/tests/test-form-urlencoded.js b/tests/test-form-urlencoded.js index 97534c225..ae2f17182 100644 --- a/tests/test-form-urlencoded.js +++ b/tests/test-form-urlencoded.js @@ -27,14 +27,15 @@ function runTest (t, options) { }) }) - server.listen(8080, function() { + server.listen(6767, function() { - request.post('http://localhost:8080', options, function(err, res, body) { + request.post('http://localhost:6767', options, function(err, res, body) { t.equal(err, null) t.equal(res.statusCode, 200) t.equal(body, 'done') - server.close() - t.end() + server.close(function() { + t.end() + }) }) }) } diff --git a/tests/test-form.js b/tests/test-form.js index f83e70b0c..75f12f95e 100644 --- a/tests/test-form.js +++ b/tests/test-form.js @@ -65,7 +65,6 @@ tape('multipart form append', function(t) { res.end('done') t.equal(FIELDS.length, 0) - t.end() }) }) @@ -82,7 +81,9 @@ tape('multipart form append', function(t) { t.equal(err, null) t.equal(res.statusCode, 200) t.equal(body, 'done') - server.close() + server.close(function() { + t.end() + }) }) var form = req.form() diff --git a/tests/test-gzip.js b/tests/test-gzip.js index 89ae968ff..5c2b3c1ae 100644 --- a/tests/test-gzip.js +++ b/tests/test-gzip.js @@ -140,6 +140,7 @@ tape('transparently supports gzip error to pipes', function(t) { }) tape('cleanup', function(t) { - server.close() - t.end() + server.close(function() { + t.end() + }) }) diff --git a/tests/test-hawk.js b/tests/test-hawk.js index 098be2ce3..bd0ac1d2e 100644 --- a/tests/test-hawk.js +++ b/tests/test-hawk.js @@ -48,6 +48,7 @@ tape('hawk', function(t) { }) tape('cleanup', function(t) { - server.close() - t.end() + server.close(function() { + t.end() + }) }) diff --git a/tests/test-http-signature.js b/tests/test-http-signature.js index 74992536d..1ad96bafa 100644 --- a/tests/test-http-signature.js +++ b/tests/test-http-signature.js @@ -103,6 +103,7 @@ tape('incorrect key', function(t) { }) tape('cleanup', function(t) { - server.close() - t.end() + server.close(function() { + t.end() + }) }) diff --git a/tests/test-httpModule.js b/tests/test-httpModule.js index 4b92a1e6b..0cb7e606d 100644 --- a/tests/test-httpModule.js +++ b/tests/test-httpModule.js @@ -100,7 +100,9 @@ run_tests('https only', { 'https:': faux_https }) run_tests('http and https', { 'http:': faux_http, 'https:': faux_https }) tape('cleanup', function(t) { - plain_server.close() - https_server.close() - t.end() + plain_server.close(function() { + https_server.close(function() { + t.end() + }) + }) }) diff --git a/tests/test-multipart.js b/tests/test-multipart.js index 7bbcb7c8c..6f0bf015c 100644 --- a/tests/test-multipart.js +++ b/tests/test-multipart.js @@ -107,8 +107,9 @@ function runTest(t, a) { t.equal(err, null) t.equal(res.statusCode, 200) t.deepEqual(body, a.json ? {status: 'done'} : 'done') - server.close() - t.end() + server.close(function() { + t.end() + }) }) }) diff --git a/tests/test-onelineproxy.js b/tests/test-onelineproxy.js index 63fad0664..73a0ae8a3 100644 --- a/tests/test-onelineproxy.js +++ b/tests/test-onelineproxy.js @@ -54,6 +54,7 @@ tape('chained one-line proxying', function(t) { }) tape('cleanup', function(t) { - server.close() - t.end() + server.close(function() { + t.end() + }) }) diff --git a/tests/test-rfc3986.js b/tests/test-rfc3986.js index d346b3efd..f8cdca1a2 100644 --- a/tests/test-rfc3986.js +++ b/tests/test-rfc3986.js @@ -44,8 +44,9 @@ function runTest (t, options) { request.post('http://localhost:8080', options, function(err, res, body) { t.equal(err, null) - server.close() - t.end() + server.close(function() { + t.end() + }) }) }) }