11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst { spawn } = require('child_process'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ciconst path = require('path'); 71cb0ef41Sopenharmony_ciconst fs = require('fs'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 101cb0ef41Sopenharmony_citmpdir.refresh(); 111cb0ef41Sopenharmony_ciconst tmpDir = tmpdir.path; 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciconst entry = path.join(tmpDir, 'entry.mjs'); 141cb0ef41Sopenharmony_ciconst real = path.join(tmpDir, 'index.mjs'); 151cb0ef41Sopenharmony_ciconst link_absolute_path = path.join(tmpDir, 'absolute.mjs'); 161cb0ef41Sopenharmony_ciconst link_relative_path = path.join(tmpDir, 'relative.mjs'); 171cb0ef41Sopenharmony_ciconst link_ignore_extension = path.join(tmpDir, 181cb0ef41Sopenharmony_ci 'ignore_extension.json'); 191cb0ef41Sopenharmony_ciconst link_directory = path.join(tmpDir, 'directory'); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_cifs.writeFileSync(real, 'export default [];'); 221cb0ef41Sopenharmony_cifs.writeFileSync(entry, ` 231cb0ef41Sopenharmony_ciimport assert from 'assert'; 241cb0ef41Sopenharmony_ciimport real from './index.mjs'; 251cb0ef41Sopenharmony_ciimport absolute from './absolute.mjs'; 261cb0ef41Sopenharmony_ciimport relative from './relative.mjs'; 271cb0ef41Sopenharmony_ciimport ignoreExtension from './ignore_extension.json'; 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ciassert.strictEqual(absolute, real); 301cb0ef41Sopenharmony_ciassert.strictEqual(relative, real); 311cb0ef41Sopenharmony_ciassert.strictEqual(ignoreExtension, real); 321cb0ef41Sopenharmony_ci`); 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_citry { 351cb0ef41Sopenharmony_ci fs.symlinkSync(real, link_absolute_path); 361cb0ef41Sopenharmony_ci fs.symlinkSync(path.basename(real), link_relative_path); 371cb0ef41Sopenharmony_ci fs.symlinkSync(real, link_ignore_extension); 381cb0ef41Sopenharmony_ci fs.symlinkSync(path.dirname(real), link_directory, 'dir'); 391cb0ef41Sopenharmony_ci} catch (err) { 401cb0ef41Sopenharmony_ci if (err.code !== 'EPERM') throw err; 411cb0ef41Sopenharmony_ci common.skip('insufficient privileges for symlinks'); 421cb0ef41Sopenharmony_ci} 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_cispawn(process.execPath, [entry], 451cb0ef41Sopenharmony_ci { stdio: 'inherit' }).on('exit', (code) => { 461cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 471cb0ef41Sopenharmony_ci}); 48