Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/sanity/src/server.test.ts
5257 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 { TestContext } from './context.js';
8
9
export function setup(context: TestContext) {
10
context.test('server-alpine-arm64', ['alpine', 'arm64'], async () => {
11
const dir = await context.downloadAndUnpack('server-alpine-arm64');
12
const entryPoint = context.getServerEntryPoint(dir);
13
await testServer(entryPoint);
14
});
15
16
context.test('server-alpine-x64', ['alpine', 'x64'], async () => {
17
const dir = await context.downloadAndUnpack('server-linux-alpine');
18
const entryPoint = context.getServerEntryPoint(dir);
19
await testServer(entryPoint);
20
});
21
22
context.test('server-darwin-arm64', ['darwin', 'arm64'], async () => {
23
const dir = await context.downloadAndUnpack('server-darwin-arm64');
24
context.validateAllCodesignSignatures(dir);
25
const entryPoint = context.getServerEntryPoint(dir);
26
await testServer(entryPoint);
27
});
28
29
context.test('server-darwin-x64', ['darwin', 'x64'], async () => {
30
const dir = await context.downloadAndUnpack('server-darwin');
31
context.validateAllCodesignSignatures(dir);
32
const entryPoint = context.getServerEntryPoint(dir);
33
await testServer(entryPoint);
34
});
35
36
context.test('server-linux-arm64', ['linux', 'arm64'], async () => {
37
const dir = await context.downloadAndUnpack('server-linux-arm64');
38
const entryPoint = context.getServerEntryPoint(dir);
39
await testServer(entryPoint);
40
});
41
42
context.test('server-linux-armhf', ['linux', 'arm32'], async () => {
43
const dir = await context.downloadAndUnpack('server-linux-armhf');
44
const entryPoint = context.getServerEntryPoint(dir);
45
await testServer(entryPoint);
46
});
47
48
context.test('server-linux-x64', ['linux', 'x64'], async () => {
49
const dir = await context.downloadAndUnpack('server-linux-x64');
50
const entryPoint = context.getServerEntryPoint(dir);
51
await testServer(entryPoint);
52
});
53
54
context.test('server-win32-arm64', ['windows', 'arm64'], async () => {
55
const dir = await context.downloadAndUnpack('server-win32-arm64');
56
context.validateAllAuthenticodeSignatures(dir);
57
const entryPoint = context.getServerEntryPoint(dir);
58
await testServer(entryPoint);
59
});
60
61
context.test('server-win32-x64', ['windows', 'x64'], async () => {
62
const dir = await context.downloadAndUnpack('server-win32-x64');
63
context.validateAllAuthenticodeSignatures(dir);
64
const entryPoint = context.getServerEntryPoint(dir);
65
await testServer(entryPoint);
66
});
67
68
async function testServer(entryPoint: string) {
69
if (context.options.downloadOnly) {
70
return;
71
}
72
73
await context.runCliApp('Server', entryPoint,
74
[
75
'--accept-server-license-terms',
76
'--connection-token', context.getRandomToken(),
77
'--host', '0.0.0.0',
78
'--port', context.getUniquePort(),
79
'--server-data-dir', context.createTempDir(),
80
'--extensions-dir', context.createTempDir()
81
],
82
async (line) => {
83
const port = /Extension host agent listening on (\d+)/.exec(line)?.[1];
84
if (!port) {
85
return false;
86
}
87
88
const url = new URL('version', context.getWebServerUrl(port)).toString();
89
90
context.log(`Fetching version from ${url}`);
91
const response = await context.fetchNoErrors(url);
92
const version = await response.text();
93
assert.strictEqual(version, context.options.commit, `Expected commit ${context.options.commit} but got ${version}`);
94
95
return true;
96
}
97
);
98
}
99
}
100
101