0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/addons/load-long-path/test.js
Vse Mozhet Byt 2d2986ae72 test: simplify test skipping
* Make common.skip() exit.

  Also add common.printSkipMessage() for partial skips.

* Don't make needless things before skip

PR-URL: https://github.com/nodejs/node/pull/14021
Fixes: https://github.com/nodejs/node/issues/14016
Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-07-04 12:41:49 +03:00

36 lines
1.1 KiB
JavaScript

'use strict';
const common = require('../../common');
if (common.isWOW64)
common.skip('doesn\'t work on WOW64');
const fs = require('fs');
const path = require('path');
const assert = require('assert');
common.refreshTmpDir();
// make a path that is more than 260 chars long.
// Any given folder cannot have a name longer than 260 characters,
// so create 10 nested folders each with 30 character long names.
let addonDestinationDir = path.resolve(common.tmpDir);
for (let i = 0; i < 10; i++) {
addonDestinationDir = path.join(addonDestinationDir, 'x'.repeat(30));
fs.mkdirSync(addonDestinationDir);
}
const addonPath = path.join(__dirname,
'build',
common.buildType,
'binding.node');
const addonDestinationPath = path.join(addonDestinationDir, 'binding.node');
// Copy binary to long path destination
const contents = fs.readFileSync(addonPath);
fs.writeFileSync(addonDestinationPath, contents);
// Attempt to load at long path destination
const addon = require(addonDestinationPath);
assert.notStrictEqual(addon, null);
assert.strictEqual(addon.hello(), 'world');