From 534c3ec52b224932f7ae152164e8cbaee6fa05c0 Mon Sep 17 00:00:00 2001 From: ChrBergert Date: Mon, 6 Nov 2017 16:04:36 +0000 Subject: [PATCH 1/5] added template for better error explanation to assert.ok error message --- test/parallel/test-child-process-spawnsync-maxbuf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-child-process-spawnsync-maxbuf.js b/test/parallel/test-child-process-spawnsync-maxbuf.js index 2d94c338bb7202..15ca9fa14aa4a6 100644 --- a/test/parallel/test-child-process-spawnsync-maxbuf.js +++ b/test/parallel/test-child-process-spawnsync-maxbuf.js @@ -16,7 +16,7 @@ const args = [ { const ret = spawnSync(process.execPath, args, { maxBuffer: 1 }); - assert.ok(ret.error, 'maxBuffer should error'); + assert.ok(ret.error, `instead of an error there is ${ret.error}` ); assert.strictEqual(ret.error.errno, 'ENOBUFS'); // We can have buffers larger than maxBuffer because underneath we alloc 64k // that matches our read sizes. From 41586a20c886aeffa89c5811cc09ad42eafa6043 Mon Sep 17 00:00:00 2001 From: ChrBergert Date: Tue, 7 Nov 2017 09:46:31 +0000 Subject: [PATCH 2/5] changed error message to a more speaking information about what happened: "child process does not error when maxBuffer is set to 1" --- test/parallel/test-child-process-spawnsync-maxbuf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-child-process-spawnsync-maxbuf.js b/test/parallel/test-child-process-spawnsync-maxbuf.js index 15ca9fa14aa4a6..11e0ce6fd4447b 100644 --- a/test/parallel/test-child-process-spawnsync-maxbuf.js +++ b/test/parallel/test-child-process-spawnsync-maxbuf.js @@ -16,7 +16,7 @@ const args = [ { const ret = spawnSync(process.execPath, args, { maxBuffer: 1 }); - assert.ok(ret.error, `instead of an error there is ${ret.error}` ); + assert.ok(ret.error, 'child process does not error when maxBuffer is set to 1' ); assert.strictEqual(ret.error.errno, 'ENOBUFS'); // We can have buffers larger than maxBuffer because underneath we alloc 64k // that matches our read sizes. From ed558f324c6fb2c7f926e3d987907393d1ac6efc Mon Sep 17 00:00:00 2001 From: ChrBergert Date: Tue, 7 Nov 2017 10:57:04 +0000 Subject: [PATCH 3/5] fixing linting issue --- test/parallel/test-child-process-spawnsync-maxbuf.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-child-process-spawnsync-maxbuf.js b/test/parallel/test-child-process-spawnsync-maxbuf.js index 11e0ce6fd4447b..fd9784c312ea4b 100644 --- a/test/parallel/test-child-process-spawnsync-maxbuf.js +++ b/test/parallel/test-child-process-spawnsync-maxbuf.js @@ -16,7 +16,8 @@ const args = [ { const ret = spawnSync(process.execPath, args, { maxBuffer: 1 }); - assert.ok(ret.error, 'child process does not error when maxBuffer is set to 1' ); + assert.ok(ret.error, 'child process does not error \ +when maxBuffer is set to 1'); assert.strictEqual(ret.error.errno, 'ENOBUFS'); // We can have buffers larger than maxBuffer because underneath we alloc 64k // that matches our read sizes. From 7d056442d544261743604f96391899c19d45b979 Mon Sep 17 00:00:00 2001 From: ChrBergert Date: Tue, 7 Nov 2017 11:23:57 +0000 Subject: [PATCH 4/5] changed line break to a more standard way --- test/parallel/test-child-process-spawnsync-maxbuf.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-child-process-spawnsync-maxbuf.js b/test/parallel/test-child-process-spawnsync-maxbuf.js index fd9784c312ea4b..8641bb226f0bc9 100644 --- a/test/parallel/test-child-process-spawnsync-maxbuf.js +++ b/test/parallel/test-child-process-spawnsync-maxbuf.js @@ -16,8 +16,8 @@ const args = [ { const ret = spawnSync(process.execPath, args, { maxBuffer: 1 }); - assert.ok(ret.error, 'child process does not error \ -when maxBuffer is set to 1'); + assert.ok(ret.error, 'child process does not error ' + + 'when maxBuffer is set to 1' ); assert.strictEqual(ret.error.errno, 'ENOBUFS'); // We can have buffers larger than maxBuffer because underneath we alloc 64k // that matches our read sizes. From 9d58db532018c4f6bbd041b6a2d9265871e71b96 Mon Sep 17 00:00:00 2001 From: ChrBergert Date: Tue, 7 Nov 2017 20:24:31 +0000 Subject: [PATCH 5/5] - removed initial change for error message - removed comment that wasn't relevant/important - added comment that explains what the test does --- test/parallel/test-child-process-spawnsync-maxbuf.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-child-process-spawnsync-maxbuf.js b/test/parallel/test-child-process-spawnsync-maxbuf.js index 8641bb226f0bc9..022c090c338d13 100644 --- a/test/parallel/test-child-process-spawnsync-maxbuf.js +++ b/test/parallel/test-child-process-spawnsync-maxbuf.js @@ -1,10 +1,12 @@ 'use strict'; require('../common'); + +// This test checks that the maxBuffer option for child_process.spawnSync() +// works as expected. + const assert = require('assert'); const spawnSync = require('child_process').spawnSync; const msgOut = 'this is stdout'; - -// This is actually not os.EOL? const msgOutBuf = Buffer.from(`${msgOut}\n`); const args = [ @@ -16,8 +18,7 @@ const args = [ { const ret = spawnSync(process.execPath, args, { maxBuffer: 1 }); - assert.ok(ret.error, 'child process does not error ' + - 'when maxBuffer is set to 1' ); + assert.ok(ret.error, 'maxBuffer should error'); assert.strictEqual(ret.error.errno, 'ENOBUFS'); // We can have buffers larger than maxBuffer because underneath we alloc 64k // that matches our read sizes.