• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../../common');
3if (common.isWindows && (process.env.PROCESSOR_ARCHITEW6432 !== undefined))
4  common.skip('doesn\'t work on WOW64');
5
6const fs = require('fs');
7const path = require('path');
8const assert = require('assert');
9
10const tmpdir = require('../../common/tmpdir');
11tmpdir.refresh();
12
13// Make a path that is more than 260 chars long.
14// Any given folder cannot have a name longer than 260 characters,
15// so create 10 nested folders each with 30 character long names.
16let addonDestinationDir = path.resolve(tmpdir.path);
17
18for (let i = 0; i < 10; i++) {
19  addonDestinationDir = path.join(addonDestinationDir, 'x'.repeat(30));
20  fs.mkdirSync(addonDestinationDir);
21}
22
23const addonPath = path.join(__dirname,
24                            'build',
25                            common.buildType,
26                            'binding.node');
27const addonDestinationPath = path.join(addonDestinationDir, 'binding.node');
28
29// Copy binary to long path destination
30const contents = fs.readFileSync(addonPath);
31fs.writeFileSync(addonDestinationPath, contents);
32
33// Attempt to load at long path destination
34const addon = require(addonDestinationPath);
35assert.notStrictEqual(addon, null);
36assert.strictEqual(addon.hello(), 'world');
37