Skip to content

Commit 9b5b730

Browse files
committed
fix: build
At some point the update server started only returning recent commits from the "commits" API. Which makes good sense, and we should be less restrictive and try to download any version that looks like a git hash.
1 parent 4becb98 commit 9b5b730

File tree

2 files changed

+94
-100
lines changed

2 files changed

+94
-100
lines changed

lib/download.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ const pipelineAsync = promisify(pipeline);
3333

3434
const vscodeStableReleasesAPI = `https://update.code.visualstudio.com/api/releases/stable`;
3535
const vscodeInsiderReleasesAPI = `https://update.code.visualstudio.com/api/releases/insider`;
36-
const vscodeInsiderCommitsAPI = (platform: string) =>
37-
`https://update.code.visualstudio.com/api/commits/insider/${platform}`;
3836

3937
const downloadDirNameFormat = /^vscode-(?<platform>[a-z]+)-(?<version>[0-9.]+)$/;
4038
const makeDownloadDirName = (platform: string, version: string) => `vscode-${platform}-${version}`;
@@ -155,10 +153,11 @@ async function isValidVersion(version: string, platform: string, timeout: number
155153
}
156154
}
157155

158-
const insiderCommits: string[] = await request.getJSON(vscodeInsiderCommitsAPI(platform), timeout);
159-
if (insiderCommits.includes(version)) {
156+
if (/^[0-9a-f]{40}$/.test(version)) {
160157
return true;
161158
}
159+
160+
return false;
162161
}
163162

164163
/**

sample/src/test/runTest.ts

Lines changed: 91 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -4,116 +4,111 @@ import * as cp from 'child_process';
44
import { runTests, downloadAndUnzipVSCode, resolveCliArgsFromVSCodeExecutablePath } from '../../..';
55

66
async function go() {
7-
try {
8-
const extensionDevelopmentPath = path.resolve(__dirname, '../../../');
9-
const extensionTestsPath = path.resolve(__dirname, './suite');
7+
const extensionDevelopmentPath = path.resolve(__dirname, '../../../');
8+
const extensionTestsPath = path.resolve(__dirname, './suite');
109

11-
/**
12-
* Basic usage
13-
*/
14-
await runTests({
15-
extensionDevelopmentPath,
16-
extensionTestsPath
17-
});
10+
/**
11+
* Basic usage
12+
*/
13+
await runTests({
14+
extensionDevelopmentPath,
15+
extensionTestsPath,
16+
});
1817

19-
const extensionTestsPath2 = path.resolve(__dirname, './suite2');
20-
const testWorkspace = path.resolve(__dirname, '../../src/test-fixtures/fixture1');
18+
const extensionTestsPath2 = path.resolve(__dirname, './suite2');
19+
const testWorkspace = path.resolve(__dirname, '../../src/test-fixtures/fixture1');
2120

22-
/**
23-
* Running another test suite on a specific workspace
24-
*/
25-
await runTests({
26-
extensionDevelopmentPath,
27-
extensionTestsPath: extensionTestsPath2,
28-
launchArgs: [testWorkspace]
29-
});
21+
/**
22+
* Running another test suite on a specific workspace
23+
*/
24+
await runTests({
25+
extensionDevelopmentPath,
26+
extensionTestsPath: extensionTestsPath2,
27+
launchArgs: [testWorkspace],
28+
});
3029

31-
/**
32-
* Use 1.36.1 release for testing
33-
*/
34-
await runTests({
35-
version: '1.36.1',
36-
extensionDevelopmentPath,
37-
extensionTestsPath,
38-
launchArgs: [testWorkspace]
39-
});
30+
/**
31+
* Use 1.36.1 release for testing
32+
*/
33+
await runTests({
34+
version: '1.36.1',
35+
extensionDevelopmentPath,
36+
extensionTestsPath,
37+
launchArgs: [testWorkspace],
38+
});
4039

41-
/**
42-
* Use Insiders release for testing
43-
*/
44-
await runTests({
45-
version: 'insiders',
46-
extensionDevelopmentPath,
47-
extensionTestsPath,
48-
launchArgs: [testWorkspace]
49-
});
40+
/**
41+
* Use Insiders release for testing
42+
*/
43+
await runTests({
44+
version: 'insiders',
45+
extensionDevelopmentPath,
46+
extensionTestsPath,
47+
launchArgs: [testWorkspace],
48+
});
5049

51-
/**
52-
* Use a specific Insiders commit for testing
53-
*/
54-
await runTests({
55-
version: '9d3fbb3d9a50055be0a8c6d721625d02c9de492d',
56-
extensionDevelopmentPath,
57-
extensionTestsPath,
58-
launchArgs: [testWorkspace]
59-
});
50+
/**
51+
* Use a specific Insiders commit for testing
52+
*/
53+
await runTests({
54+
version: '9d3fbb3d9a50055be0a8c6d721625d02c9de492d',
55+
extensionDevelopmentPath,
56+
extensionTestsPath,
57+
launchArgs: [testWorkspace],
58+
});
6059

61-
/**
62-
* Noop, since 1.36.1 already downloaded to .vscode-test/vscode-1.36.1
63-
*/
64-
await downloadAndUnzipVSCode('1.36.1');
60+
/**
61+
* Noop, since 1.36.1 already downloaded to .vscode-test/vscode-1.36.1
62+
*/
63+
await downloadAndUnzipVSCode('1.36.1');
6564

66-
/**
67-
* Manually download VS Code 1.35.0 release for testing.
68-
*/
69-
const vscodeExecutablePath = await downloadAndUnzipVSCode('1.35.0');
70-
await runTests({
71-
vscodeExecutablePath,
72-
extensionDevelopmentPath,
73-
extensionTestsPath,
74-
launchArgs: [testWorkspace]
75-
});
65+
/**
66+
* Manually download VS Code 1.35.0 release for testing.
67+
*/
68+
const vscodeExecutablePath = await downloadAndUnzipVSCode('1.35.0');
69+
await runTests({
70+
vscodeExecutablePath,
71+
extensionDevelopmentPath,
72+
extensionTestsPath,
73+
launchArgs: [testWorkspace],
74+
});
7675

77-
/**
78-
* Install Python extension
79-
*/
80-
const [cli, ...args] = resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath);
81-
cp.spawnSync(cli, [...args, '--install-extension', 'ms-python.python'], {
82-
encoding: 'utf-8',
83-
stdio: 'inherit'
84-
});
76+
/**
77+
* Install Python extension
78+
*/
79+
const [cli, ...args] = resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath);
80+
cp.spawnSync(cli, [...args, '--install-extension', 'ms-python.python'], {
81+
encoding: 'utf-8',
82+
stdio: 'inherit',
83+
});
84+
85+
/**
86+
* - Add additional launch flags for VS Code
87+
* - Pass custom environment variables to test runner
88+
*/
89+
await runTests({
90+
vscodeExecutablePath,
91+
extensionDevelopmentPath,
92+
extensionTestsPath,
93+
launchArgs: [
94+
testWorkspace,
95+
// This disables all extensions except the one being testing
96+
'--disable-extensions',
97+
],
98+
// Custom environment variables for extension test script
99+
extensionTestsEnv: { foo: 'bar' },
100+
});
85101

86-
/**
87-
* - Add additional launch flags for VS Code
88-
* - Pass custom environment variables to test runner
89-
*/
102+
/**
103+
* Use win64 instead of win32 for testing Windows
104+
*/
105+
if (process.platform === 'win32') {
90106
await runTests({
91-
vscodeExecutablePath,
92107
extensionDevelopmentPath,
93108
extensionTestsPath,
94-
launchArgs: [
95-
testWorkspace,
96-
// This disables all extensions except the one being testing
97-
'--disable-extensions'
98-
],
99-
// Custom environment variables for extension test script
100-
extensionTestsEnv: { foo: 'bar' }
109+
version: '1.40.0',
110+
platform: 'win32-x64-archive',
101111
});
102-
103-
/**
104-
* Use win64 instead of win32 for testing Windows
105-
*/
106-
if (process.platform === 'win32') {
107-
await runTests({
108-
extensionDevelopmentPath,
109-
extensionTestsPath,
110-
version: '1.40.0',
111-
platform: 'win32-x64-archive'
112-
});
113-
}
114-
} catch (err) {
115-
console.error('Failed to run tests');
116-
process.exit(1);
117112
}
118113
}
119114

0 commit comments

Comments
 (0)