summaryrefslogtreecommitdiff
path: root/test/parallel/test-module-loading-error.js
diff options
context:
space:
mode:
authorRefael Ackermann <refack@gmail.com>2017-06-03 10:20:11 -0400
committerRefael Ackermann <refack@gmail.com>2017-06-05 17:20:16 -0400
commit30a20bda7daf24d7ee6c1f8d07249a1f12e75aba (patch)
tree809c501793890b937c80cfbb61ecc4b6d736aedb /test/parallel/test-module-loading-error.js
parentefab7847c682d2e3d63223e8724d64480a7f8aec (diff)
downloadandroid-node-v8-30a20bda7daf24d7ee6c1f8d07249a1f12e75aba.tar.gz
android-node-v8-30a20bda7daf24d7ee6c1f8d07249a1f12e75aba.tar.bz2
android-node-v8-30a20bda7daf24d7ee6c1f8d07249a1f12e75aba.zip
test,module: make message check MUI dependent
PR-URL: https://github.com/nodejs/node/pull/13393 Fixes: https://github.com/nodejs/node/issues/13376 Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'test/parallel/test-module-loading-error.js')
-rw-r--r--test/parallel/test-module-loading-error.js27
1 files changed, 21 insertions, 6 deletions
diff --git a/test/parallel/test-module-loading-error.js b/test/parallel/test-module-loading-error.js
index fb8ddf5a66..5cdf918260 100644
--- a/test/parallel/test-module-loading-error.js
+++ b/test/parallel/test-module-loading-error.js
@@ -22,23 +22,38 @@
'use strict';
const common = require('../common');
const assert = require('assert');
+const { execSync } = require('child_process');
-const error_desc = {
+const errorMessagesByPlatform = {
win32: ['%1 is not a valid Win32 application'],
linux: ['file too short', 'Exec format error'],
sunos: ['unknown file type', 'not an ELF file'],
darwin: ['file too short']
};
-const dlerror_msg = error_desc[process.platform];
+// If we don't know a priori what the error would be, we accept anything.
+const errorMessages = errorMessagesByPlatform[process.platform] || [''];
+
+// On Windows, error messages are MUI dependent
+// Ref: https://github.com/nodejs/node/issues/13376
+let localeOk = true;
+if (common.isWindows) {
+ const powerShellFindMUI =
+ 'powershell -NoProfile -ExecutionPolicy Unrestricted -c ' +
+ '"(Get-UICulture).TwoLetterISOLanguageName"';
+ try {
+ // If MUI != 'en' we'll ignore the content of the message
+ localeOk = execSync(powerShellFindMUI).toString('utf8').trim() === 'en';
+ } catch (_) {
+ // It's only a best effort try to find the MUI
+ }
+}
assert.throws(
() => { require('../fixtures/module-loading-error.node'); },
(e) => {
- if (dlerror_msg && !dlerror_msg.some((msg) => e.message.includes(msg)))
- return false;
- if (e.name !== 'Error')
+ if (localeOk && !errorMessages.some((msg) => e.message.includes(msg)))
return false;
- return true;
+ return e.name === 'Error';
}
);