mirror of
https://github.com/nodejs/node.git
synced 2025-05-18 11:29:35 +00:00

common.js needs to be loaded in all tests so that there is checking for variable leaks and possibly other things. However, it does not need to be assigned to a variable if nothing in common.js is referred to elsewhere in the test. PR-URL: https://github.com/nodejs/node/pull/4408 Reviewed-By: James M Snell <jasnell@gmail.com>
39 lines
864 B
JavaScript
39 lines
864 B
JavaScript
'use strict';
|
|
require('../common');
|
|
var assert = require('assert');
|
|
|
|
console.error('load test-module-loading-error.js');
|
|
|
|
var 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']
|
|
};
|
|
var dlerror_msg = error_desc[process.platform];
|
|
|
|
if (!dlerror_msg) {
|
|
console.log('1..0 # Skipped: platform not supported.');
|
|
return;
|
|
}
|
|
|
|
try {
|
|
require('../fixtures/module-loading-error.node');
|
|
} catch (e) {
|
|
assert.strictEqual(dlerror_msg.some((errMsgCase) => {
|
|
return e.toString().indexOf(errMsgCase) !== -1;
|
|
}), true);
|
|
}
|
|
|
|
try {
|
|
require();
|
|
} catch (e) {
|
|
assert.notEqual(e.toString().indexOf('missing path'), -1);
|
|
}
|
|
|
|
try {
|
|
require({});
|
|
} catch (e) {
|
|
assert.notEqual(e.toString().indexOf('path must be a string'), -1);
|
|
}
|