2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-01-13 21:42:45 +01:00
|
|
|
const common = require('../common');
|
2018-03-08 02:24:08 +05:30
|
|
|
|
2017-07-01 02:29:09 +03:00
|
|
|
// This test is only relevant on Windows.
|
|
|
|
if (!common.isWindows)
|
|
|
|
common.skip('Windows specific test.');
|
|
|
|
|
2018-03-08 02:24:08 +05:30
|
|
|
// This test ensures fs.realpathSync works on properly on Windows without
|
|
|
|
// throwing ENOENT when the path involves a fileserver.
|
|
|
|
// https://github.com/nodejs/node-v0.x-archive/issues/3542
|
|
|
|
|
2016-01-13 21:42:45 +01:00
|
|
|
const assert = require('assert');
|
|
|
|
const fs = require('fs');
|
2018-09-26 14:00:08 +03:00
|
|
|
const os = require('os');
|
2016-01-13 21:42:45 +01:00
|
|
|
const path = require('path');
|
2012-06-27 01:59:25 +02:00
|
|
|
|
|
|
|
function test(p) {
|
2017-01-08 13:19:00 +00:00
|
|
|
const result = fs.realpathSync(p);
|
2016-04-11 17:48:34 +03:00
|
|
|
assert.strictEqual(result.toLowerCase(), path.resolve(p).toLowerCase());
|
2012-06-27 01:59:25 +02:00
|
|
|
|
2020-09-06 22:27:07 +02:00
|
|
|
fs.realpath(p, common.mustSucceed((result) => {
|
2016-04-11 17:48:34 +03:00
|
|
|
assert.strictEqual(result.toLowerCase(), path.resolve(p).toLowerCase());
|
2016-07-15 15:43:24 -04:00
|
|
|
}));
|
2012-06-27 01:59:25 +02:00
|
|
|
}
|
|
|
|
|
2018-09-26 14:00:08 +03:00
|
|
|
test(`//${os.hostname()}/c$/Windows/System32`);
|
|
|
|
test(`//${os.hostname()}/c$/Windows`);
|
|
|
|
test(`//${os.hostname()}/c$/`);
|
|
|
|
test(`\\\\${os.hostname()}\\c$\\`);
|
2016-04-11 17:48:34 +03:00
|
|
|
test('C:\\');
|
|
|
|
test('C:');
|
2012-06-27 01:59:25 +02:00
|
|
|
test(process.env.windir);
|