forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
32 lines (26 loc) · 1014 Bytes
/
test.js
File metadata and controls
32 lines (26 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
const common = require('../../common');
const fs = require('fs');
const path = require('path');
const assert = require('assert');
common.refreshTmpDir();
var destDir = path.resolve(common.tmpDir);
var location = [path.join(destDir, 'first'), path.join(destDir, 'second')];
fs.mkdirSync(location[0]);
try {
fs.symlinkSync(location[0], location[1]);
} catch (EPERM) {
common.skip('module identity test (no privs for symlinks)');
return;
}
const addonPath = path.join(__dirname, 'build', 'Release', 'binding.node');
var contents = fs.readFileSync(addonPath);
fs.writeFileSync(path.join(location[0], 'binding.node'), contents);
fs.writeFileSync(path.join(location[1], 'binding.node'), contents);
var primary = require(path.join(location[0], 'binding.node'));
assert(primary != null);
assert(primary.hello() == 'world');
var secondary = require(path.join(location[1], 'binding.node'));
assert(secondary != null);
assert(secondary.hello() == 'world');
require('./submodule').test(location[1]);