From 0767eba8b3b0ff8d0f84c399d3b59cfa86847fd5 Mon Sep 17 00:00:00 2001 From: sagirk Date: Mon, 19 Nov 2018 15:11:13 +0530 Subject: [PATCH 1/3] test: refactor test-child-process-env to use arrow functions In `test/parallel/test-child-process-env.js`, callbacks use anonymous closure functions. It is safe to replace them with arrow functions since these callbacks don't contain references to `this`, `super` or `arguments`. This results in shorter functions. --- test/parallel/test-child-process-env.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-child-process-env.js b/test/parallel/test-child-process-env.js index 2eec658872518a..1e398ff26afee9 100644 --- a/test/parallel/test-child-process-env.js +++ b/test/parallel/test-child-process-env.js @@ -48,12 +48,12 @@ let response = ''; child.stdout.setEncoding('utf8'); -child.stdout.on('data', function(chunk) { +child.stdout.on('data', (chunk) => { console.log(`stdout: ${chunk}`); response += chunk; }); -process.on('exit', function() { +process.on('exit', () => { assert.ok(response.includes('HELLO=WORLD')); assert.ok(response.includes('FOO=BAR')); assert.ok(!response.includes('UNDEFINED=undefined')); From 91fa0e1a617ff6aec4904dbe738b0769afc3e408 Mon Sep 17 00:00:00 2001 From: sagirk Date: Tue, 20 Nov 2018 13:31:06 +0530 Subject: [PATCH 2/3] test: wrap functions containing assertions inside a `common.mustCall` --- test/parallel/test-child-process-env.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-child-process-env.js b/test/parallel/test-child-process-env.js index 1e398ff26afee9..90a2671c7fbc90 100644 --- a/test/parallel/test-child-process-env.js +++ b/test/parallel/test-child-process-env.js @@ -53,10 +53,10 @@ child.stdout.on('data', (chunk) => { response += chunk; }); -process.on('exit', () => { +process.on('exit', common.mustCall(() => { assert.ok(response.includes('HELLO=WORLD')); assert.ok(response.includes('FOO=BAR')); assert.ok(!response.includes('UNDEFINED=undefined')); assert.ok(response.includes('NULL=null')); assert.ok(response.includes(`EMPTY=${os.EOL}`)); -}); +})); From dc4bdabf534b44d67d485ef6870bfdfba9fa6db2 Mon Sep 17 00:00:00 2001 From: sagirk Date: Wed, 21 Nov 2018 13:26:38 +0530 Subject: [PATCH 3/3] Revert "test: wrap functions containing assertions inside a `common.mustCall`" This reverts commit 91fa0e1a617ff6aec4904dbe738b0769afc3e408. --- test/parallel/test-child-process-env.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-child-process-env.js b/test/parallel/test-child-process-env.js index 90a2671c7fbc90..1e398ff26afee9 100644 --- a/test/parallel/test-child-process-env.js +++ b/test/parallel/test-child-process-env.js @@ -53,10 +53,10 @@ child.stdout.on('data', (chunk) => { response += chunk; }); -process.on('exit', common.mustCall(() => { +process.on('exit', () => { assert.ok(response.includes('HELLO=WORLD')); assert.ok(response.includes('FOO=BAR')); assert.ok(!response.includes('UNDEFINED=undefined')); assert.ok(response.includes('NULL=null')); assert.ok(response.includes(`EMPTY=${os.EOL}`)); -})); +});