From 2afa3d8a03f1f0798d83dc57abc252bb78b7e591 Mon Sep 17 00:00:00 2001 From: Timothy J Fontaine Date: Wed, 15 Oct 2014 18:23:42 -0700 Subject: [PATCH] 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. --- test/simple/test-crypto-domains.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/simple/test-crypto-domains.js b/test/simple/test-crypto-domains.js index 0562fe45b00..5c383860d14 100644 --- a/test/simple/test-crypto-domains.js +++ b/test/simple/test-crypto-domains.js @@ -26,7 +26,9 @@ var d = domain.create(); var expect = ['pbkdf2', 'randomBytes', 'pseudoRandomBytes'] 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 () { @@ -42,3 +44,7 @@ d.run(function () { throw new Error('pseudoRandomBytes'); }); }); + +process.on('exit', function () { + assert.strictEqual(expect.length, 0, 'we should have seen all error messages'); +});