xref: /third_party/node/test/parallel/test-os-userinfo-handles-getter-errors.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci// Tests that os.userInfo correctly handles errors thrown by option property
31cb0ef41Sopenharmony_ci// getters. See https://github.com/nodejs/node/issues/12370.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst common = require('../common');
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ciconst execFile = require('child_process').execFile;
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst script = `os.userInfo({
101cb0ef41Sopenharmony_ci  get encoding() {
111cb0ef41Sopenharmony_ci    throw new Error('xyz');
121cb0ef41Sopenharmony_ci  }
131cb0ef41Sopenharmony_ci})`;
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciconst node = process.execPath;
161cb0ef41Sopenharmony_ciexecFile(node, [ '-e', script ], common.mustCall((err, stdout, stderr) => {
171cb0ef41Sopenharmony_ci  assert(stderr.includes('Error: xyz'), 'userInfo crashes');
181cb0ef41Sopenharmony_ci}));
19

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