11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciif (!common.isWindows) 51cb0ef41Sopenharmony_ci common.skip('Test for Windows only'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst assert = require('assert'); 101cb0ef41Sopenharmony_ciconst fs = require('fs'); 111cb0ef41Sopenharmony_ciconst spawnSync = require('child_process').spawnSync; 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_cilet result; 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci// Create a subst drive 161cb0ef41Sopenharmony_ciconst driveLetters = 'ABCDEFGHIJKLMNOPQRSTUWXYZ'; 171cb0ef41Sopenharmony_cilet drive; 181cb0ef41Sopenharmony_cilet i; 191cb0ef41Sopenharmony_cifor (i = 0; i < driveLetters.length; ++i) { 201cb0ef41Sopenharmony_ci drive = `${driveLetters[i]}:`; 211cb0ef41Sopenharmony_ci result = spawnSync('subst', [drive, fixtures.fixturesDir]); 221cb0ef41Sopenharmony_ci if (result.status === 0) 231cb0ef41Sopenharmony_ci break; 241cb0ef41Sopenharmony_ci} 251cb0ef41Sopenharmony_ciif (i === driveLetters.length) 261cb0ef41Sopenharmony_ci common.skip('Cannot create subst drive'); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci// Schedule cleanup (and check if all callbacks where called) 291cb0ef41Sopenharmony_ciprocess.on('exit', function() { 301cb0ef41Sopenharmony_ci spawnSync('subst', ['/d', drive]); 311cb0ef41Sopenharmony_ci}); 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci// test: 341cb0ef41Sopenharmony_ciconst filename = `${drive}\\empty.js`; 351cb0ef41Sopenharmony_ciconst filenameBuffer = Buffer.from(filename); 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ciresult = fs.realpathSync(filename); 381cb0ef41Sopenharmony_ciassert.strictEqual(result, filename); 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ciresult = fs.realpathSync(filename, 'buffer'); 411cb0ef41Sopenharmony_ciassert(Buffer.isBuffer(result)); 421cb0ef41Sopenharmony_ciassert(result.equals(filenameBuffer)); 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_cifs.realpath(filename, common.mustSucceed((result) => { 451cb0ef41Sopenharmony_ci assert.strictEqual(result, filename); 461cb0ef41Sopenharmony_ci})); 471cb0ef41Sopenharmony_ci 481cb0ef41Sopenharmony_cifs.realpath(filename, 'buffer', common.mustSucceed((result) => { 491cb0ef41Sopenharmony_ci assert(Buffer.isBuffer(result)); 501cb0ef41Sopenharmony_ci assert(result.equals(filenameBuffer)); 511cb0ef41Sopenharmony_ci})); 52