mirror of
https://github.com/nodejs/node.git
synced 2025-05-10 17:57:53 +00:00

In test-fs-realpath-on-substed-drive, require common/fixtures module and swapped the location of fixturesDir from common to fixtures module. PR-URL: https://github.com/nodejs/node/pull/16813 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.isWindows)
|
|
common.skip('Test for Windows only');
|
|
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const spawnSync = require('child_process').spawnSync;
|
|
|
|
let result;
|
|
|
|
// create a subst drive
|
|
const driveLetters = 'ABCDEFGHIJKLMNOPQRSTUWXYZ';
|
|
let drive;
|
|
let i;
|
|
for (i = 0; i < driveLetters.length; ++i) {
|
|
drive = `${driveLetters[i]}:`;
|
|
result = spawnSync('subst', [drive, fixtures.fixturesDir]);
|
|
if (result.status === 0)
|
|
break;
|
|
}
|
|
if (i === driveLetters.length)
|
|
common.skip('Cannot create subst drive');
|
|
|
|
// 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.ifError(err);
|
|
assert.strictEqual(result, filename);
|
|
}));
|
|
|
|
fs.realpath(filename, 'buffer', common.mustCall(function(err, result) {
|
|
assert.ifError(err);
|
|
assert(Buffer.isBuffer(result));
|
|
assert(result.equals(filenameBuffer));
|
|
}));
|