node/test/parallel/test-icu-data-dir.js
ZYSzys dcc5e51e1c tools: force common be required before any other modules
PR-URL: https://github.com/nodejs/node/pull/27650
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-05-13 19:39:34 +08:00

28 lines
824 B
JavaScript

// Flags: --expose-internals
'use strict';
const common = require('../common');
const { internalBinding } = require('internal/test/binding');
const os = require('os');
const { hasSmallICU } = internalBinding('config');
if (!(common.hasIntl && hasSmallICU))
common.skip('missing Intl');
const assert = require('assert');
const { spawnSync } = require('child_process');
const expected =
'could not initialize ICU (check NODE_ICU_DATA or ' +
`--icu-data-dir parameters)${os.EOL}`;
{
const child = spawnSync(process.execPath, ['--icu-data-dir=/', '-e', '0']);
assert(child.stderr.toString().includes(expected));
}
{
const env = Object.assign({}, process.env, { NODE_ICU_DATA: '/' });
const child = spawnSync(process.execPath, ['-e', '0'], { env });
assert(child.stderr.toString().includes(expected));
}