[Pkg-javascript-commits] [node-async] 394/480: use domains to stop error bubbling in #420 test
Jonas Smedegaard
js at moszumanska.debian.org
Fri May 2 08:58:45 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository node-async.
commit 95fec40c0c64ff221611e07bc59230314c3da665
Author: Caolan McMahon <caolan at caolanmcmahon.com>
Date: Fri Mar 28 14:42:14 2014 +0000
use domains to stop error bubbling in #420 test
---
test/test-async.js | 42 +++++++++++++++++++++++++++++-------------
1 file changed, 29 insertions(+), 13 deletions(-)
diff --git a/test/test-async.js b/test/test-async.js
index 0948672..3d62bf8 100755
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -433,22 +433,38 @@ exports['auto removeListener has side effect on loop iterator'] = function(test)
// Issue 410 on github: https://github.com/caolan/async/issues/410
exports['auto calls callback multiple times'] = function(test) {
+ if (typeof process === 'undefined') {
+ // node only test
+ return;
+ }
var finalCallCount = 0;
- async.auto({
- task1: function(callback) { callback(null); },
- task2: ['task1', function(callback) { callback(null); }]
- },
-
- // Error throwing final callback. This should only run once
- function(err) {
- finalCallCount++;
- if (finalCallCount > 1) {
- test.done(new Error("Final auto callback should only be called once"));
- } else {
- test.done();
- throw new Error("An error");
+ var domain = require('domain').create();
+ domain.on('error', function (e) {
+ // ignore test error
+ if (!e._test_error) {
+ return test.done(e);
}
});
+ domain.run(function () {
+ async.auto({
+ task1: function(callback) { callback(null); },
+ task2: ['task1', function(callback) { callback(null); }]
+ },
+
+ // Error throwing final callback. This should only run once
+ function(err) {
+ finalCallCount++;
+ var e = new Error("An error");
+ e._test_error = true;
+ throw e;
+ });
+ });
+ setTimeout(function () {
+ test.equal(finalCallCount, 1,
+ "Final auto callback should only be called once"
+ );
+ test.done();
+ }, 10);
};
exports['waterfall'] = function(test){
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-async.git
More information about the Pkg-javascript-commits
mailing list