Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/environment/test/node/nativeModules.integrationTest.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import assert from 'assert';
7
import { isMacintosh, isWindows } from '../../../../base/common/platform.js';
8
import { flakySuite } from '../../../../base/test/common/testUtils.js';
9
10
function testErrorMessage(module: string): string {
11
return `Unable to load "${module}" dependency. It was probably not compiled for the right operating system architecture or had missing build tools.`;
12
}
13
14
flakySuite('Native Modules (all platforms)', () => {
15
16
(isMacintosh ? test.skip : test)('kerberos', async () => { // Somehow fails on macOS ARM?
17
const { default: kerberos } = await import('kerberos');
18
assert.ok(typeof kerberos.initializeClient === 'function', testErrorMessage('kerberos'));
19
});
20
21
test('yauzl', async () => {
22
const { default: yauzl } = await import('yauzl');
23
assert.ok(typeof yauzl.ZipFile === 'function', testErrorMessage('yauzl'));
24
});
25
26
test('yazl', async () => {
27
const { default: yazl } = await import('yazl');
28
assert.ok(typeof yazl.ZipFile === 'function', testErrorMessage('yazl'));
29
});
30
31
test('v8-inspect-profiler', async () => {
32
const { default: profiler } = await import('v8-inspect-profiler');
33
assert.ok(typeof profiler.startProfiling === 'function', testErrorMessage('v8-inspect-profiler'));
34
});
35
36
test('native-is-elevated', async () => {
37
const { default: isElevated } = await import('native-is-elevated');
38
assert.ok(typeof isElevated === 'function', testErrorMessage('native-is-elevated '));
39
40
const result = isElevated();
41
assert.ok(typeof result === 'boolean', testErrorMessage('native-is-elevated'));
42
});
43
44
test('native-keymap', async () => {
45
const keyMap = await import('native-keymap');
46
assert.ok(typeof keyMap.onDidChangeKeyboardLayout === 'function', testErrorMessage('native-keymap'));
47
assert.ok(typeof keyMap.getCurrentKeyboardLayout === 'function', testErrorMessage('native-keymap'));
48
49
const result = keyMap.getCurrentKeyboardLayout();
50
assert.ok(result, testErrorMessage('native-keymap'));
51
});
52
53
test('native-watchdog', async () => {
54
const watchDog = await import('native-watchdog');
55
assert.ok(typeof watchDog.start === 'function', testErrorMessage('native-watchdog'));
56
});
57
58
test('@vscode/sudo-prompt', async () => {
59
const prompt = await import('@vscode/sudo-prompt');
60
assert.ok(typeof prompt.exec === 'function', testErrorMessage('@vscode/sudo-prompt'));
61
});
62
63
test('@vscode/policy-watcher', async () => {
64
const watcher = await import('@vscode/policy-watcher');
65
assert.ok(typeof watcher.createWatcher === 'function', testErrorMessage('@vscode/policy-watcher'));
66
});
67
68
test('node-pty', async () => {
69
const nodePty = await import('node-pty');
70
assert.ok(typeof nodePty.spawn === 'function', testErrorMessage('node-pty'));
71
});
72
73
test('@vscode/spdlog', async () => {
74
const spdlog = await import('@vscode/spdlog');
75
assert.ok(typeof spdlog.createRotatingLogger === 'function', testErrorMessage('@vscode/spdlog'));
76
assert.ok(typeof spdlog.version === 'number', testErrorMessage('@vscode/spdlog'));
77
});
78
79
test('@parcel/watcher', async () => {
80
const parcelWatcher = await import('@parcel/watcher');
81
assert.ok(typeof parcelWatcher.subscribe === 'function', testErrorMessage('@parcel/watcher'));
82
});
83
84
test('@vscode/deviceid', async () => {
85
const deviceIdPackage = await import('@vscode/deviceid');
86
assert.ok(typeof deviceIdPackage.getDeviceId === 'function', testErrorMessage('@vscode/deviceid'));
87
});
88
89
test('@vscode/ripgrep', async () => {
90
const ripgrep = await import('@vscode/ripgrep');
91
assert.ok(typeof ripgrep.rgPath === 'string', testErrorMessage('@vscode/ripgrep'));
92
});
93
94
test('vscode-regexpp', async () => {
95
const regexpp = await import('vscode-regexpp');
96
assert.ok(typeof regexpp.RegExpParser === 'function', testErrorMessage('vscode-regexpp'));
97
});
98
99
test('@vscode/sqlite3', async () => {
100
const { default: sqlite3 } = await import('@vscode/sqlite3');
101
assert.ok(typeof sqlite3.Database === 'function', testErrorMessage('@vscode/sqlite3'));
102
});
103
104
test('http-proxy-agent', async () => {
105
const { default: mod } = await import('http-proxy-agent');
106
assert.ok(typeof mod.HttpProxyAgent === 'function', testErrorMessage('http-proxy-agent'));
107
});
108
109
test('https-proxy-agent', async () => {
110
const { default: mod } = await import('https-proxy-agent');
111
assert.ok(typeof mod.HttpsProxyAgent === 'function', testErrorMessage('https-proxy-agent'));
112
});
113
114
test('@vscode/proxy-agent', async () => {
115
const proxyAgent = await import('@vscode/proxy-agent');
116
// This call will load `@vscode/proxy-agent` which is a native module that we want to test on Windows
117
const windowsCerts = await proxyAgent.loadSystemCertificates({
118
log: {
119
trace: () => { },
120
debug: () => { },
121
info: () => { },
122
warn: () => { },
123
error: () => { }
124
}
125
});
126
assert.ok(windowsCerts.length > 0, testErrorMessage('@vscode/proxy-agent'));
127
});
128
});
129
130
(!isWindows ? suite.skip : suite)('Native Modules (Windows)', () => {
131
132
test('@vscode/windows-mutex', async () => {
133
const mutex = await import('@vscode/windows-mutex');
134
assert.ok(mutex && typeof mutex.isActive === 'function', testErrorMessage('@vscode/windows-mutex'));
135
assert.ok(typeof mutex.isActive === 'function', testErrorMessage('@vscode/windows-mutex'));
136
assert.ok(typeof mutex.Mutex === 'function', testErrorMessage('@vscode/windows-mutex'));
137
});
138
139
test('windows-foreground-love', async () => {
140
const foregroundLove = await import('windows-foreground-love');
141
assert.ok(typeof foregroundLove.allowSetForegroundWindow === 'function', testErrorMessage('windows-foreground-love'));
142
143
const result = foregroundLove.allowSetForegroundWindow(process.pid);
144
assert.ok(typeof result === 'boolean', testErrorMessage('windows-foreground-love'));
145
});
146
147
test('@vscode/windows-process-tree', async () => {
148
const processTree = await import('@vscode/windows-process-tree');
149
assert.ok(typeof processTree.getProcessTree === 'function', testErrorMessage('@vscode/windows-process-tree'));
150
151
return new Promise((resolve, reject) => {
152
processTree.getProcessTree(process.pid, tree => {
153
if (tree) {
154
resolve();
155
} else {
156
reject(new Error(testErrorMessage('@vscode/windows-process-tree')));
157
}
158
});
159
});
160
});
161
162
test('@vscode/windows-registry', async () => {
163
const windowsRegistry = await import('@vscode/windows-registry');
164
assert.ok(typeof windowsRegistry.GetStringRegKey === 'function', testErrorMessage('@vscode/windows-registry'));
165
166
const result = windowsRegistry.GetStringRegKey('HKEY_LOCAL_MACHINE', 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion', 'EditionID');
167
assert.ok(typeof result === 'string' || typeof result === 'undefined', testErrorMessage('@vscode/windows-registry'));
168
});
169
});
170
171