2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2017-02-01 21:05:29 -08:00
|
|
|
require('../common');
|
2016-12-30 18:38:06 -05:00
|
|
|
const assert = require('assert');
|
2012-02-26 21:26:09 +09:00
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const error_desc = {
|
2015-11-16 10:59:39 -03:00
|
|
|
win32: ['%1 is not a valid Win32 application'],
|
|
|
|
linux: ['file too short', 'Exec format error'],
|
2015-11-18 08:07:15 -06:00
|
|
|
sunos: ['unknown file type', 'not an ELF file'],
|
|
|
|
darwin: ['file too short']
|
2012-02-26 21:26:09 +09:00
|
|
|
};
|
2017-01-08 13:19:00 +00:00
|
|
|
const dlerror_msg = error_desc[process.platform];
|
2012-02-26 21:26:09 +09:00
|
|
|
|
2017-02-01 21:05:29 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
);
|
2014-09-09 10:22:37 +08:00
|
|
|
|
2017-02-01 21:05:29 -08:00
|
|
|
assert.throws(
|
|
|
|
require,
|
|
|
|
/^AssertionError: missing path$/
|
|
|
|
);
|
2014-09-09 10:22:37 +08:00
|
|
|
|
2017-02-01 21:05:29 -08:00
|
|
|
assert.throws(
|
|
|
|
() => { require({}); },
|
|
|
|
/^AssertionError: path must be a string$/
|
|
|
|
);
|