xref: /third_party/node/test/parallel/test-os-homedir-no-envvar.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ciconst cp = require('child_process');
51cb0ef41Sopenharmony_ciconst os = require('os');
61cb0ef41Sopenharmony_ciconst path = require('path');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciif (process.argv[2] === 'child') {
101cb0ef41Sopenharmony_ci  if (common.isWindows)
111cb0ef41Sopenharmony_ci    assert.strictEqual(process.env.USERPROFILE, undefined);
121cb0ef41Sopenharmony_ci  else
131cb0ef41Sopenharmony_ci    assert.strictEqual(process.env.HOME, undefined);
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci  const home = os.homedir();
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci  assert.strictEqual(typeof home, 'string');
181cb0ef41Sopenharmony_ci  assert(home.includes(path.sep));
191cb0ef41Sopenharmony_ci} else {
201cb0ef41Sopenharmony_ci  if (common.isWindows)
211cb0ef41Sopenharmony_ci    delete process.env.USERPROFILE;
221cb0ef41Sopenharmony_ci  else
231cb0ef41Sopenharmony_ci    delete process.env.HOME;
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ci  const child = cp.spawnSync(process.execPath, [__filename, 'child'], {
261cb0ef41Sopenharmony_ci    env: process.env
271cb0ef41Sopenharmony_ci  });
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci  assert.strictEqual(child.status, 0);
301cb0ef41Sopenharmony_ci}
31

Indexes created Thu Nov 07 10:32:03 CST 2024