-
Notifications
You must be signed in to change notification settings - Fork 28.3k
/
test-policy-dependencies.js
111 lines (107 loc) Β· 2.43 KB
/
test-policy-dependencies.js
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
common.requireNoPackageJSONAbove();
const fixtures = require('../common/fixtures');
const assert = require('assert');
const { spawnSync } = require('child_process');
const dep = fixtures.path('policy', 'parent.js');
{
const depPolicy = fixtures.path(
'policy',
'dependencies',
'dependencies-redirect-policy.json');
const { status } = spawnSync(
process.execPath,
[
'--experimental-policy', depPolicy, dep,
]
);
assert.strictEqual(status, 0);
}
{
const depPolicy = fixtures.path(
'policy',
'dependencies',
'dependencies-redirect-builtin-policy.json');
const { status } = spawnSync(
process.execPath,
[
'--experimental-policy', depPolicy, dep,
]
);
assert.strictEqual(status, 0);
}
{
const depPolicy = fixtures.path(
'policy',
'dependencies',
'dependencies-redirect-unknown-builtin-policy.json');
const { status } = spawnSync(
process.execPath,
[
'--experimental-policy', depPolicy, dep,
]
);
assert.strictEqual(status, 1);
}
{
const depPolicy = fixtures.path(
'policy',
'dependencies',
'dependencies-wildcard-policy.json');
const { status } = spawnSync(
process.execPath,
[
'--experimental-policy', depPolicy, dep,
]
);
assert.strictEqual(status, 0);
}
{
const depPolicy = fixtures.path(
'policy',
'dependencies',
'dependencies-empty-policy.json');
const { status } = spawnSync(
process.execPath,
[
'--experimental-policy', depPolicy, dep,
]
);
assert.strictEqual(status, 1);
}
{
const depPolicy = fixtures.path(
'policy',
'dependencies',
'dependencies-missing-policy.json');
const { status } = spawnSync(
process.execPath,
[
'--experimental-policy', depPolicy, dep,
]
);
assert.strictEqual(status, 1);
}
{
// Regression test for https://github.com/nodejs/node/issues/37812
const depPolicy = fixtures.path(
'policy',
'dependencies',
'dependencies-missing-export-policy.json');
const { status, stderr } = spawnSync(
process.execPath,
[
'--experimental-policy',
depPolicy,
fixtures.path('policy', 'bad-main.mjs'),
]
);
assert.strictEqual(status, 1);
assert.match(
`${stderr}`,
/SyntaxError: Named export 'doesNotExist' not found\./,
'Should give the real SyntaxError and position');
}