diff options
author | Bartosz Sosnowski <bartosz@janeasystems.com> | 2016-07-27 00:18:35 +0200 |
---|---|---|
committer | Bartosz Sosnowski <bartosz@janeasystems.com> | 2016-08-12 13:07:55 +0200 |
commit | 08996fde3c08c0cfabc7cc3fe332d83f674ab099 (patch) | |
tree | 92af7158c6f0ca59a31c7d176bfdaf65c0c7b2e7 /test/parallel/test-fs-realpath-on-substed-drive.js | |
parent | f6070a1a02d946b0caad7ee8bee3c2d583ebad4b (diff) | |
download | android-node-v8-08996fde3c08c0cfabc7cc3fe332d83f674ab099.tar.gz android-node-v8-08996fde3c08c0cfabc7cc3fe332d83f674ab099.tar.bz2 android-node-v8-08996fde3c08c0cfabc7cc3fe332d83f674ab099.zip |
fs: restore JS implementation of realpath
This reverts parts of https://github.com/nodejs/node/commit/b488b19eaf2b2e7a3ca5eccd2445e245847a5f76
restoring javascript implementation of realpath and realpathSync.
Fixes: https://github.com/nodejs/node/issues/7175
Fixes: https://github.com/nodejs/node/issues/6861
Fixes: https://github.com/nodejs/node/issues/7294
Fixes: https://github.com/nodejs/node/issues/7192
Fixes: https://github.com/nodejs/node/issues/7044
Fixes: https://github.com/nodejs/node/issues/6624
Fixes: https://github.com/nodejs/node/issues/6978
PR-URL: https://github.com/nodejs/node/pull/7899
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test/parallel/test-fs-realpath-on-substed-drive.js')
-rw-r--r-- | test/parallel/test-fs-realpath-on-substed-drive.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/parallel/test-fs-realpath-on-substed-drive.js b/test/parallel/test-fs-realpath-on-substed-drive.js new file mode 100644 index 0000000000..c910936269 --- /dev/null +++ b/test/parallel/test-fs-realpath-on-substed-drive.js @@ -0,0 +1,53 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); +const spawnSync = require('child_process').spawnSync; + +if (!common.isWindows) { + common.skip('Test for Windows only'); + return; +} +let result; + +// create a subst drive +const driveLetters = 'ABCDEFGHIJKLMNOPQRSTUWXYZ'; +let drive; +for (var i = 0; i < driveLetters.length; ++i) { + drive = `${driveLetters[i]}:`; + result = spawnSync('subst', [drive, common.fixturesDir]); + if (result.status === 0) + break; +} +if (i === driveLetters.length) { + common.skip('Cannot create subst drive'); + return; +} + +// schedule cleanup (and check if all callbacks where called) +process.on('exit', function() { + spawnSync('subst', ['/d', drive]); +}); + +// test: +const filename = `${drive}\\empty.js`; +const filenameBuffer = Buffer.from(filename); + +result = fs.realpathSync(filename); +assert.strictEqual(result, filename); + +result = fs.realpathSync(filename, 'buffer'); +assert(Buffer.isBuffer(result)); +assert(result.equals(filenameBuffer)); + +fs.realpath(filename, common.mustCall(function(err, result) { + assert(!err); + assert.strictEqual(result, filename); +})); + +fs.realpath(filename, 'buffer', common.mustCall(function(err, result) { + assert(!err); + assert(Buffer.isBuffer(result)); + assert(result.equals(filenameBuffer)); +})); |