You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

'use strict';
const common = require('../../common');
const fs = require('fs');
const path = require('path');
const assert = require('assert');
// This test verifies that symlinked native modules can be required multiple
// times without error. The symlinked module and the non-symlinked module
// should be the same instance. This expectation was not previously being
// tested and ended up being broken by https://github.com/nodejs/node/pull/5950.
// This test should pass in Node.js v4 and v5. This test will pass in Node.js
// with https://github.com/nodejs/node/pull/5950 reverted.
common.refreshTmpDir();
test: enable addons test to pass with debug build Currently when running configure with the --debug option in combination with the tests (./configure --debug && make -j8 test) there are a few addon tests that fail with error messages similar to this: === release test === Path: addons/load-long-path/test fs.js:558 return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); ^ Error: ENOENT: no such file or directory, open '/nodejs/node/test/addons/load-long-path/build/Release/binding.node' at Object.fs.openSync (fs.js:558:18) at Object.fs.readFileSync (fs.js:468:33) at Object.<anonymous> (/nodejs/node/test/addons/load-long-path/test.js:28:19) at Module._compile (module.js:560:32) at Object.Module._extensions..js (module.js:569:10) at Module.load (module.js:477:32) at tryModuleLoad (module.js:436:12) at Function.Module._load (module.js:428:3) at Module.runMain (module.js:594:10) at run (bootstrap_node.js:382:7) Command: out/Release/node /nodejs/node/test/addons/load-long-path/test.js This commit allows for the tests to pass even if the configured build type is of type debug. PR-URL: https://github.com/nodejs/node/pull/8836 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
8 years ago
const addonPath = path.join(__dirname, 'build', common.buildType);
const addonLink = path.join(common.tmpDir, 'addon');
try {
fs.symlinkSync(addonPath, addonLink);
} catch (err) {
if (err.code !== 'EPERM') throw err;
common.skip('module identity test (no privs for symlinks)');
}
const sub = require('./submodule');
[addonPath, addonLink].forEach((i) => {
const mod = require(path.join(i, 'binding.node'));
assert.notStrictEqual(mod, null);
assert.strictEqual(mod.hello(), 'world');
assert.doesNotThrow(() => sub.test(i));
});