From e9e90c800457cff05b6135a5292fcb7e3bd55b7c Mon Sep 17 00:00:00 2001 From: Clarence Dimitri CHARLES Date: Sun, 19 Feb 2017 18:30:15 +0100 Subject: [PATCH 1/8] test: add regex to match error message --- test/parallel/test-fs-realpath.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index 331cec5ee8c8bb..8bd492b3350c42 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -201,9 +201,11 @@ function test_cyclic_link_protection(callback) { fs.symlinkSync(t[1], t[0], 'dir'); unlink.push(t[0]); }); - assert.throws(function() { fs.realpathSync(entry); }); + assert.throws(function() { fs.realpathSync(entry); }, /^Error: ELOOP: too many/); asynctest(fs.realpath, [entry], callback, function(err, result) { - assert.ok(err && true); + assert.ok(err.code === 'ELOOP'); + assert.ok(err.path === entry); + assert.ok(result === undefined); return true; }); } From 123510f1fe9d206f4a1ee9b245de5968b15c4577 Mon Sep 17 00:00:00 2001 From: Clarence Dimitri CHARLES Date: Wed, 22 Feb 2017 08:39:06 +0100 Subject: [PATCH 2/8] test: lint error correction --- test/parallel/test-fs-realpath.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index 8bd492b3350c42..73dbc3972596e0 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -201,10 +201,10 @@ function test_cyclic_link_protection(callback) { fs.symlinkSync(t[1], t[0], 'dir'); unlink.push(t[0]); }); - assert.throws(function() { fs.realpathSync(entry); }, /^Error: ELOOP: too many/); + assert.throws(function() { fs.realpathSync(entry); }, /^Error: ELOOP/); asynctest(fs.realpath, [entry], callback, function(err, result) { assert.ok(err.code === 'ELOOP'); - assert.ok(err.path === entry); + assert.ok(err.path === entry); assert.ok(result === undefined); return true; }); From 0a3902b752ebb580301ca896fa6ca34fa8d382f2 Mon Sep 17 00:00:00 2001 From: Clarence Dimitri CHARLES Date: Sun, 19 Feb 2017 18:30:15 +0100 Subject: [PATCH 3/8] test: add regex to match error message --- test/parallel/test-fs-realpath.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index 73dbc3972596e0..8bd492b3350c42 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -201,10 +201,10 @@ function test_cyclic_link_protection(callback) { fs.symlinkSync(t[1], t[0], 'dir'); unlink.push(t[0]); }); - assert.throws(function() { fs.realpathSync(entry); }, /^Error: ELOOP/); + assert.throws(function() { fs.realpathSync(entry); }, /^Error: ELOOP: too many/); asynctest(fs.realpath, [entry], callback, function(err, result) { assert.ok(err.code === 'ELOOP'); - assert.ok(err.path === entry); + assert.ok(err.path === entry); assert.ok(result === undefined); return true; }); From c76fbf15b5f6b1b8ff30c5c1d8a2580de186b26a Mon Sep 17 00:00:00 2001 From: Clarence Dimitri CHARLES Date: Wed, 22 Feb 2017 08:39:06 +0100 Subject: [PATCH 4/8] test: lint error correction --- test/parallel/test-fs-realpath.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index 8bd492b3350c42..73dbc3972596e0 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -201,10 +201,10 @@ function test_cyclic_link_protection(callback) { fs.symlinkSync(t[1], t[0], 'dir'); unlink.push(t[0]); }); - assert.throws(function() { fs.realpathSync(entry); }, /^Error: ELOOP: too many/); + assert.throws(function() { fs.realpathSync(entry); }, /^Error: ELOOP/); asynctest(fs.realpath, [entry], callback, function(err, result) { assert.ok(err.code === 'ELOOP'); - assert.ok(err.path === entry); + assert.ok(err.path === entry); assert.ok(result === undefined); return true; }); From 214b8dedfeec36dbc539b9e465a5a79d0099aa0a Mon Sep 17 00:00:00 2001 From: Clarence Dimitri CHARLES Date: Sat, 25 Feb 2017 12:48:19 +0100 Subject: [PATCH 5/8] test: test assertions improvements --- test/parallel/test-fs-realpath.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index 73dbc3972596e0..387ea467d8eb6f 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -201,13 +201,15 @@ function test_cyclic_link_protection(callback) { fs.symlinkSync(t[1], t[0], 'dir'); unlink.push(t[0]); }); - assert.throws(function() { fs.realpathSync(entry); }, /^Error: ELOOP/); - asynctest(fs.realpath, [entry], callback, function(err, result) { - assert.ok(err.code === 'ELOOP'); - assert.ok(err.path === entry); - assert.ok(result === undefined); - return true; - }); + assert.throws(() => { + fs.realpathSync(entry); + }, common.expectsError('ELOOP', Error)); + asynctest( + fs.realpath, [entry], callback, common.mustCall(function(err, result) { + assert.ok(err.path === entry); + assert.ok(result === undefined); + return true; + })); } function test_cyclic_link_overprotection(callback) { From d7d0ce7cd4d6b438ca280891e59bdb6d15107005 Mon Sep 17 00:00:00 2001 From: Clarence Dimitri CHARLES Date: Tue, 28 Feb 2017 02:26:14 +0100 Subject: [PATCH 6/8] test: update the call of the function common.expectsError --- test/parallel/test-fs-realpath.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index 387ea467d8eb6f..1e8c701d4343db 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -203,7 +203,7 @@ function test_cyclic_link_protection(callback) { }); assert.throws(() => { fs.realpathSync(entry); - }, common.expectsError('ELOOP', Error)); + }, common.expectsError({ code: 'ELOOP', type: Error })); asynctest( fs.realpath, [entry], callback, common.mustCall(function(err, result) { assert.ok(err.path === entry); From 36d520417fc654fabe2c1b530d8476a16a3b0bf8 Mon Sep 17 00:00:00 2001 From: Clarence Dimitri CHARLES Date: Wed, 1 Mar 2017 00:18:09 +0100 Subject: [PATCH 7/8] test: tests assertions improvments --- test/parallel/test-fs-realpath.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index 1e8c701d4343db..bf62bf124f3136 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -206,8 +206,8 @@ function test_cyclic_link_protection(callback) { }, common.expectsError({ code: 'ELOOP', type: Error })); asynctest( fs.realpath, [entry], callback, common.mustCall(function(err, result) { - assert.ok(err.path === entry); - assert.ok(result === undefined); + assert.strictEqual(err.path, entry); + assert.strictEqual(result, undefined); return true; })); } From a3301818040411aa0aab9abbfa895e47d50d3497 Mon Sep 17 00:00:00 2001 From: Clarence Dimitri CHARLES Date: Fri, 3 Mar 2017 01:02:19 +0100 Subject: [PATCH 8/8] test: path entry fixed using path.join() --- test/parallel/test-fs-realpath.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index bf62bf124f3136..96a6deae8af0f6 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -191,11 +191,11 @@ function test_cyclic_link_protection(callback) { common.skip('symlink test (no privs)'); return runNextTest(); } - const entry = common.tmpDir + '/cycles/realpath-3a'; + const entry = path.join(common.tmpDir, '/cycles/realpath-3a'); [ [entry, '../cycles/realpath-3b'], - [common.tmpDir + '/cycles/realpath-3b', '../cycles/realpath-3c'], - [common.tmpDir + '/cycles/realpath-3c', '../cycles/realpath-3a'] + [path.join(common.tmpDir, '/cycles/realpath-3b'), '../cycles/realpath-3c'], + [path.join(common.tmpDir, '/cycles/realpath-3c'), '../cycles/realpath-3a'] ].forEach(function(t) { try { fs.unlinkSync(t[0]); } catch (e) {} fs.symlinkSync(t[1], t[0], 'dir');