From 74eb632483df591683c5bae11fda2ce794bd6684 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 14 Oct 2015 21:22:55 -0700 Subject: [PATCH] test: apply correct assert.fail() arguments The assert.fail function signature has the message as the third argument but, understandably, it is often assumed that it is the first argument (or at least the first argument if no other arguments are passed). This corrects the assert.fail() invocations in the Node.js tests. Before: assert.fail('message'); // result: AssertionError: 'message' undefined undefined After: assert.fail(null, null, 'message'); // result: AssertionError: message PR-URL: https://github.com/nodejs/node/pull/3378 Reviewed-By: Colin Ihrig --- test/internet/test-dgram-send-cb-quelches-error.js | 2 +- test/parallel/test-fs-write-stream.js | 2 +- test/parallel/test-http-header-response-splitting.js | 2 +- test/parallel/test-http-localaddress-bind-error.js | 2 +- test/parallel/test-https-localaddress-bind-error.js | 2 +- test/parallel/test-net-connect-paused-connection.js | 2 +- test/parallel/test-net-write-slow.js | 2 +- test/parallel/test-path-parse-format.js | 2 +- test/parallel/test-repl-reset-event.js | 2 +- test/parallel/test-repl.js | 2 +- test/parallel/test-spawn-cmd-named-pipe.js | 2 +- test/parallel/test-stream2-base64-single-char-read-end.js | 2 +- test/parallel/test-tick-processor.js | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/internet/test-dgram-send-cb-quelches-error.js b/test/internet/test-dgram-send-cb-quelches-error.js index e89306b2c29aa2..dbbd8fc9fd7f58 100644 --- a/test/internet/test-dgram-send-cb-quelches-error.js +++ b/test/internet/test-dgram-send-cb-quelches-error.js @@ -28,7 +28,7 @@ function callbackOnly(err) { } function onEvent(err) { - assert.fail('Error should not be emitted if there is callback'); + assert.fail(null, null, 'Error should not be emitted if there is callback'); } function onError(err) { diff --git a/test/parallel/test-fs-write-stream.js b/test/parallel/test-fs-write-stream.js index 3142e896325f6a..af3ae17ec7e7e1 100644 --- a/test/parallel/test-fs-write-stream.js +++ b/test/parallel/test-fs-write-stream.js @@ -24,7 +24,7 @@ common.refreshTmpDir(); var stream = fs.createWriteStream(file); stream.on('drain', function() { - assert.fail('\'drain\' event must not be emitted before ' + + assert.fail(null, null, '\'drain\' event must not be emitted before ' + 'stream.write() has been called at least once.'); }); stream.destroy(); diff --git a/test/parallel/test-http-header-response-splitting.js b/test/parallel/test-http-header-response-splitting.js index ad8cc9c5ba8e8f..437793a524f22f 100644 --- a/test/parallel/test-http-header-response-splitting.js +++ b/test/parallel/test-http-header-response-splitting.js @@ -27,7 +27,7 @@ var server = http.createServer(function(req, res) { res.writeHead(200, { b: header }); break; default: - assert.fail('unreachable'); + assert.fail(null, null, 'unreachable'); } res.write(responseBody); if (testIndex % 8 < 4) { diff --git a/test/parallel/test-http-localaddress-bind-error.js b/test/parallel/test-http-localaddress-bind-error.js index 80c7cab7c8e1ad..9a4bde26cd22d6 100644 --- a/test/parallel/test-http-localaddress-bind-error.js +++ b/test/parallel/test-http-localaddress-bind-error.js @@ -24,7 +24,7 @@ server.listen(common.PORT, '127.0.0.1', function() { method: 'GET', localAddress: invalidLocalAddress }, function(res) { - assert.fail('unexpectedly got response from server'); + assert.fail(null, null, 'unexpectedly got response from server'); }).on('error', function(e) { console.log('client got error: ' + e.message); gotError = true; diff --git a/test/parallel/test-https-localaddress-bind-error.js b/test/parallel/test-https-localaddress-bind-error.js index b3cb4ffe6b077b..66551a780aed9e 100644 --- a/test/parallel/test-https-localaddress-bind-error.js +++ b/test/parallel/test-https-localaddress-bind-error.js @@ -35,7 +35,7 @@ server.listen(common.PORT, '127.0.0.1', function() { method: 'GET', localAddress: invalidLocalAddress }, function(res) { - assert.fail('unexpectedly got response from server'); + assert.fail(null, null, 'unexpectedly got response from server'); }).on('error', function(e) { console.log('client got error: ' + e.message); gotError = true; diff --git a/test/parallel/test-net-connect-paused-connection.js b/test/parallel/test-net-connect-paused-connection.js index 60af9e44fb31f6..bb258ef009a657 100644 --- a/test/parallel/test-net-connect-paused-connection.js +++ b/test/parallel/test-net-connect-paused-connection.js @@ -11,5 +11,5 @@ net.createServer(function(conn) { net.connect(common.PORT, 'localhost').pause(); setTimeout(function() { - assert.fail('expected to exit'); + assert.fail(null, null, 'expected to exit'); }, 1000).unref(); diff --git a/test/parallel/test-net-write-slow.js b/test/parallel/test-net-write-slow.js index 4b8163984f556a..8ded93ee71a8d3 100644 --- a/test/parallel/test-net-write-slow.js +++ b/test/parallel/test-net-write-slow.js @@ -14,7 +14,7 @@ var server = net.createServer(function(socket) { socket.setNoDelay(); socket.setTimeout(1000); socket.on('timeout', function() { - assert.fail('flushed: ' + flushed + + assert.fail(null, null, 'flushed: ' + flushed + ', received: ' + received + '/' + SIZE * N); }); diff --git a/test/parallel/test-path-parse-format.js b/test/parallel/test-path-parse-format.js index 709ede698acebc..c8913d2dfc56e4 100644 --- a/test/parallel/test-path-parse-format.js +++ b/test/parallel/test-path-parse-format.js @@ -89,7 +89,7 @@ function checkErrors(path) { return; } - assert.fail('should have thrown'); + assert.fail(null, null, 'should have thrown'); }); } diff --git a/test/parallel/test-repl-reset-event.js b/test/parallel/test-repl-reset-event.js index e6157956d43a65..e6d4eed1385b10 100644 --- a/test/parallel/test-repl-reset-event.js +++ b/test/parallel/test-repl-reset-event.js @@ -45,7 +45,7 @@ function testResetGlobal(cb) { } var timeout = setTimeout(function() { - assert.fail('Timeout, REPL did not emit reset events'); + assert.fail(null, null, 'Timeout, REPL did not emit reset events'); }, 5000); testReset(function() { diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 83a9025bec0151..ac4c9012e906f6 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -389,5 +389,5 @@ function unix_test() { unix_test(); timer = setTimeout(function() { - assert.fail('Timeout'); + assert.fail(null, null, 'Timeout'); }, 5000); diff --git a/test/parallel/test-spawn-cmd-named-pipe.js b/test/parallel/test-spawn-cmd-named-pipe.js index c664f7f358c37b..5371577e6c458c 100644 --- a/test/parallel/test-spawn-cmd-named-pipe.js +++ b/test/parallel/test-spawn-cmd-named-pipe.js @@ -39,7 +39,7 @@ if (!process.argv[2]) { const comspec = process.env['comspec']; if (!comspec || comspec.length === 0) { - assert.fail('Failed to get COMSPEC'); + assert.fail(null, null, 'Failed to get COMSPEC'); } const args = ['/c', process.execPath, __filename, 'child', diff --git a/test/parallel/test-stream2-base64-single-char-read-end.js b/test/parallel/test-stream2-base64-single-char-read-end.js index e50ea5a0cc1370..2d60877de83662 100644 --- a/test/parallel/test-stream2-base64-single-char-read-end.js +++ b/test/parallel/test-stream2-base64-single-char-read-end.js @@ -33,5 +33,5 @@ src.on('end', function() { src.pipe(dst); timeout = setTimeout(function() { - assert.fail('timed out waiting for _write'); + assert.fail(null, null, 'timed out waiting for _write'); }, 100); diff --git a/test/parallel/test-tick-processor.js b/test/parallel/test-tick-processor.js index d6bf642bba38ce..cd110e1a87ed3d 100644 --- a/test/parallel/test-tick-processor.js +++ b/test/parallel/test-tick-processor.js @@ -40,7 +40,7 @@ function runTest(pattern, code) { return /^isolate-/.test(file); }); if (matches.length != 1) { - assert.fail('There should be a single log file.'); + assert.fail(null, null, 'There should be a single log file.'); } var log = matches[0]; var out = cp.execSync(process.execPath + ' ' + processor +