diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2013-11-16 20:46:54 +0400 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2013-12-10 23:17:00 +0400 |
commit | f16edd2632930e3fbfead4d6d52eeac87824f1a6 (patch) | |
tree | 286ce474a141f3afae619922dc03384675c42d76 /test | |
parent | 4a2792cd2f86403a71edf65d82600b6aad5713bf (diff) | |
download | node-new-f16edd2632930e3fbfead4d6d52eeac87824f1a6.tar.gz |
fs: report correct path when EEXIST
When `symlink`, `link` or `rename` report EEXIST, ENOTEMPTY or EPERM -
the destination file name should be included in the error message,
instead of source file name.
fix #6510
Diffstat (limited to 'test')
-rw-r--r-- | test/simple/test-fs-error-messages.js | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/test/simple/test-fs-error-messages.js b/test/simple/test-fs-error-messages.js index 772966bd60..773faa69d7 100644 --- a/test/simple/test-fs-error-messages.js +++ b/test/simple/test-fs-error-messages.js @@ -28,7 +28,10 @@ var assert = require('assert'); var path = require('path'), fs = require('fs'), fn = path.join(common.fixturesDir, 'non-existent'), - existingFile = path.join(common.fixturesDir, 'exit.js'); + existingFile = path.join(common.fixturesDir, 'exit.js'), + existingFile2 = path.join(common.fixturesDir, 'create-file.js'), + existingDir = path.join(common.fixturesDir, 'empty'), + existingDir2 = path.join(common.fixturesDir, 'keys'); // ASYNC_CALL @@ -49,6 +52,10 @@ fs.link(fn, 'foo', function(err) { assert.ok(0 <= err.message.indexOf(fn)); }); +fs.link(existingFile, existingFile2, function(err) { + assert.ok(0 <= err.message.indexOf(existingFile2)); +}); + fs.unlink(fn, function(err) { assert.ok(0 <= err.message.indexOf(fn)); }); @@ -57,6 +64,10 @@ fs.rename(fn, 'foo', function(err) { assert.ok(0 <= err.message.indexOf(fn)); }); +fs.rename(existingDir, existingDir2, function(err) { + assert.ok(0 <= err.message.indexOf(existingDir2)); +}); + fs.rmdir(fn, function(err) { assert.ok(0 <= err.message.indexOf(fn)); }); @@ -136,6 +147,14 @@ try { try { ++expected; + fs.linkSync(existingFile, existingFile2); +} catch (err) { + errors.push('link'); + assert.ok(0 <= err.message.indexOf(existingFile2)); +} + +try { + ++expected; fs.unlinkSync(fn); } catch (err) { errors.push('unlink'); @@ -176,6 +195,14 @@ try { try { ++expected; + fs.renameSync(existingDir, existingDir2); +} catch (err) { + errors.push('rename'); + assert.ok(0 <= err.message.indexOf(existingDir2)); +} + +try { + ++expected; fs.readdirSync(fn); } catch (err) { errors.push('readdir'); |