In test-module-loading-error: * Do not skip the rest of the test just because we are running on a platform for which the test does not know the expected system error message. Simply skip the message validation but run the remainder of the test. * Use assert.throws() in place of try/catch * Make checks more strict. Instead of partial string matches, match the entire string. Add check for Error name to at least do some validation in situations where we do not have the system error message. PR-URL: https://github.com/nodejs/node/pull/11116 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
33 lines
737 B
JavaScript
33 lines
737 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
const error_desc = {
|
|
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];
|
|
|
|
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')
|
|
return false;
|
|
return true;
|
|
}
|
|
);
|
|
|
|
assert.throws(
|
|
require,
|
|
/^AssertionError: missing path$/
|
|
);
|
|
|
|
assert.throws(
|
|
() => { require({}); },
|
|
/^AssertionError: path must be a string$/
|
|
);
|