0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-icu-data-dir.js
Joyee Cheung 8b45c5d26a src: improve error message when ICU data cannot be initialized
Previously when we fail to initialize ICU data, the error message is

```
could not initialize ICU (check NODE_ICU_DATA or --icu-data-dir
parameters)
```

This patch updates it to something similar to:

```
U_FILE_ACCESS_ERROR: Could not initialize ICU. Check the directory
specified by NODE_ICU_DATA or --icu-data-dir contains icudt73l.dat
and it's readable
```

Where the expected data file name is the same as U_ICUDATA_NAME.

PR-URL: https://github.com/nodejs/node/pull/49666
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2023-09-22 13:24:22 +00:00

34 lines
727 B
JavaScript

// Flags: --expose-internals
'use strict';
const common = require('../common');
const { spawnSyncAndExit } = require('../common/child_process');
const { internalBinding } = require('internal/test/binding');
const { hasSmallICU } = internalBinding('config');
if (!(common.hasIntl && hasSmallICU))
common.skip('missing Intl');
{
spawnSyncAndExit(
process.execPath,
['--icu-data-dir=/', '-e', '0'],
{
status: 9,
signal: null,
stderr: /Could not initialize ICU/
});
}
{
const env = { ...process.env, NODE_ICU_DATA: '/' };
spawnSyncAndExit(
process.execPath,
['-e', '0'],
{ env },
{
status: 9,
signal: null,
stderr: /Could not initialize ICU/
});
}