test: crypto-domains avoid spurious failures

The order of the callbacks is non-deterministic, so don't expect the
error messages to come back in the same order every time, instead just
verify they are expected messages.
pull/23395/head
Timothy J Fontaine 2014-10-15 18:23:42 -07:00
parent d601c76f4d
commit 2afa3d8a03
1 changed files with 7 additions and 1 deletions

View File

@ -26,7 +26,9 @@ var d = domain.create();
var expect = ['pbkdf2', 'randomBytes', 'pseudoRandomBytes'] var expect = ['pbkdf2', 'randomBytes', 'pseudoRandomBytes']
d.on('error', function (e) { d.on('error', function (e) {
assert.equal(e.message, expect.shift()); var idx = expect.indexOf(e.message);
assert.notEqual(idx, -1, 'we should have error: ' + e.message);
expect.splice(idx, 1);
}); });
d.run(function () { d.run(function () {
@ -42,3 +44,7 @@ d.run(function () {
throw new Error('pseudoRandomBytes'); throw new Error('pseudoRandomBytes');
}); });
}); });
process.on('exit', function () {
assert.strictEqual(expect.length, 0, 'we should have seen all error messages');
});