diff --git a/test/smoke/src/main.ts b/test/smoke/src/main.ts index e2657a9e4df95..ef9e04f39bfd4 100644 --- a/test/smoke/src/main.ts +++ b/test/smoke/src/main.ts @@ -263,30 +263,31 @@ async function setupRepository(): Promise { async function ensureStableCode(): Promise { let stableCodePath = opts['stable-build']; if (!stableCodePath) { - const { major, minor } = parseVersion(version!); - const majorMinorVersion = `${major}.${minor - 1}`; - const versionsReq = await retry(() => measureAndLog(() => fetch('https://update.code.visualstudio.com/api/releases/stable', { headers: { 'x-api-version': '2' } }), 'versionReq', logger), 1000, 20); + const current = parseVersion(version!); + const versionsReq = await retry(() => measureAndLog(() => fetch('https://update.code.visualstudio.com/api/releases/stable'), 'versionReq', logger), 1000, 20); if (!versionsReq.ok) { throw new Error('Could not fetch releases from update server'); } - const versions: { version: string }[] = await measureAndLog(() => versionsReq.json(), 'versionReq.json()', logger); - const prefix = `${majorMinorVersion}.`; - const previousVersion = versions.find(v => v.version.startsWith(prefix)); + const versions: string[] = await measureAndLog(() => versionsReq.json(), 'versionReq.json()', logger); + const stableVersion = versions.find(raw => { + const version = parseVersion(raw); + return version.major < current.major || (version.major === current.major && version.minor < current.minor); + }); - if (!previousVersion) { - throw new Error(`Could not find suitable stable version ${majorMinorVersion}`); + if (!stableVersion) { + throw new Error(`Could not find suitable stable version for ${version}`); } - logger.log(`Found VS Code v${version}, downloading previous VS Code version ${previousVersion.version}...`); + logger.log(`Found VS Code v${version}, downloading previous VS Code version ${stableVersion}...`); let lastProgressMessage: string | undefined = undefined; let lastProgressReportedAt = 0; const stableCodeDestination = path.join(testDataPath, 's'); const stableCodeExecutable = await retry(() => measureAndLog(() => vscodetest.download({ cachePath: stableCodeDestination, - version: previousVersion.version, + version: stableVersion, extractSync: true, reporter: { report: report => {