2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-05-11 15:34:52 -04:00
|
|
|
const common = require('../common');
|
2016-12-30 18:38:06 -05:00
|
|
|
const assert = require('assert');
|
2012-02-26 21:26:09 +09:00
|
|
|
|
2015-09-26 15:49:04 -07:00
|
|
|
console.error('load test-module-loading-error.js');
|
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
|
|
|
|
|
|
|
if (!dlerror_msg) {
|
2016-05-11 15:34:52 -04:00
|
|
|
common.skip('platform not supported.');
|
2015-07-07 20:55:55 +05:30
|
|
|
return;
|
2012-02-26 21:26:09 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
require('../fixtures/module-loading-error.node');
|
|
|
|
} catch (e) {
|
2015-11-16 10:59:39 -03:00
|
|
|
assert.strictEqual(dlerror_msg.some((errMsgCase) => {
|
|
|
|
return e.toString().indexOf(errMsgCase) !== -1;
|
|
|
|
}), true);
|
2012-02-26 21:26:09 +09:00
|
|
|
}
|
2014-09-09 10:22:37 +08:00
|
|
|
|
|
|
|
try {
|
|
|
|
require();
|
|
|
|
} catch (e) {
|
2016-12-30 10:09:13 -05:00
|
|
|
assert.ok(e.toString().includes('missing path'));
|
2014-09-09 10:22:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
require({});
|
|
|
|
} catch (e) {
|
2016-12-30 10:09:13 -05:00
|
|
|
assert.ok(e.toString().includes('path must be a string'));
|
2014-09-09 10:22:37 +08:00
|
|
|
}
|