• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4if (!common.isWindows)
5  common.skip('Test for Windows only');
6
7const fixtures = require('../common/fixtures');
8
9const assert = require('assert');
10const fs = require('fs');
11const spawnSync = require('child_process').spawnSync;
12
13let result;
14
15// Create a subst drive
16const driveLetters = 'ABCDEFGHIJKLMNOPQRSTUWXYZ';
17let drive;
18let i;
19for (i = 0; i < driveLetters.length; ++i) {
20  drive = `${driveLetters[i]}:`;
21  result = spawnSync('subst', [drive, fixtures.fixturesDir]);
22  if (result.status === 0)
23    break;
24}
25if (i === driveLetters.length)
26  common.skip('Cannot create subst drive');
27
28// Schedule cleanup (and check if all callbacks where called)
29process.on('exit', function() {
30  spawnSync('subst', ['/d', drive]);
31});
32
33// test:
34const filename = `${drive}\\empty.js`;
35const filenameBuffer = Buffer.from(filename);
36
37result = fs.realpathSync(filename);
38assert.strictEqual(result, filename);
39
40result = fs.realpathSync(filename, 'buffer');
41assert(Buffer.isBuffer(result));
42assert(result.equals(filenameBuffer));
43
44fs.realpath(filename, common.mustSucceed((result) => {
45  assert.strictEqual(result, filename);
46}));
47
48fs.realpath(filename, 'buffer', common.mustSucceed((result) => {
49  assert(Buffer.isBuffer(result));
50  assert(result.equals(filenameBuffer));
51}));
52