Skip to content

Commit d9f5620

Browse files
authored
Merge pull request dotnet#4796 from JoeRobich/fix-release-tests
Update release tests to validate per-platform package building
2 parents 89a6414 + d45828a commit d9f5620

File tree

3 files changed

+43
-38
lines changed

3 files changed

+43
-38
lines changed

tasks/offlinePackagingTasks.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ import { getRuntimeDependenciesPackages } from '../src/tools/RuntimeDependencyPa
2323
import { getAbsolutePathPackagesToInstall } from '../src/packageManager/getAbsolutePathPackagesToInstall';
2424
import { isValidDownload } from '../src/packageManager/isValidDownload';
2525

26+
export const offlinePackages = [
27+
{ platformInfo: new PlatformInformation('win32', 'x86_64'), id: "win32-x64" },
28+
{ platformInfo: new PlatformInformation('win32', 'x86'), id: "win32-ia32" },
29+
{ platformInfo: new PlatformInformation('win32', 'arm64'), id: "win32-arm64" },
30+
{ platformInfo: new PlatformInformation('linux', 'x86_64'), id: "linux-x64" },
31+
{ platformInfo: new PlatformInformation('darwin', 'x86_64'), id: "darwin-x64" },
32+
{ platformInfo: new PlatformInformation('darwin', 'arm64'), id: "darwin-arm64" },
33+
];
34+
35+
export function getPackageName(packageJSON: any, vscodePlatformId: string) {
36+
const name = packageJSON.name;
37+
const version = packageJSON.version;
38+
return `${name}.${version}-${vscodePlatformId}.vsix`;
39+
}
40+
2641
gulp.task('vsix:offline:package', async () => {
2742

2843
if (process.platform === 'win32') {
@@ -53,44 +68,30 @@ async function doPackageOffline() {
5368
}
5469

5570
const packageJSON = getPackageJSON();
56-
const name = packageJSON.name;
57-
const version = packageJSON.version;
58-
const packageName = name + '.' + version;
59-
60-
const packages = [
61-
{ platformInfo: new PlatformInformation('win32', 'x86_64'), id: "win32-x64" },
62-
{ platformInfo: new PlatformInformation('win32', 'x86'), id: "win32-ia32" },
63-
{ platformInfo: new PlatformInformation('win32', 'arm64'), id: "win32-arm64" },
64-
{ platformInfo: new PlatformInformation('linux', 'x86_64'), id: "linux-x64" },
65-
{ platformInfo: new PlatformInformation('darwin', 'x86_64'), id: "darwin-x64" },
66-
{ platformInfo: new PlatformInformation('darwin', 'arm64'), id: "darwin-arm64" },
67-
];
68-
69-
for (let p of packages) {
70-
try
71-
{
72-
await doOfflinePackage(p.platformInfo, p.id, packageName, packageJSON, packedVsixOutputRoot);
71+
72+
for (let p of offlinePackages) {
73+
try {
74+
await doOfflinePackage(p.platformInfo, p.id, packageJSON, packedVsixOutputRoot);
7375
}
74-
catch (err)
75-
{
76-
// NOTE: Extra `\n---` at the end is because gulp will print this message following by the
76+
catch (err) {
77+
// NOTE: Extra `\n---` at the end is because gulp will print this message following by the
7778
// stack trace of this line. So that seperates the two stack traces.
7879
throw Error(`Failed to create package ${p.id}. ${err.stack ?? err ?? '<unknown error>'}\n---`);
7980
}
8081
}
8182
}
8283

8384
async function cleanAsync(deleteVsix: boolean) {
84-
await del([ 'install.*', '.omnisharp*', '.debugger', '.razor']);
85+
await del(['install.*', '.omnisharp*', '.debugger', '.razor']);
8586

8687
if (deleteVsix) {
8788
await del('*.vsix');
8889
}
8990
}
9091

91-
async function doOfflinePackage(platformInfo: PlatformInformation, vscodePlatformId: string, packageName: string, packageJSON: any, outputFolder: string) {
92+
async function doOfflinePackage(platformInfo: PlatformInformation, vscodePlatformId: string, packageJSON: any, outputFolder: string) {
9293
await cleanAsync(false);
93-
const packageFileName = `${packageName}-${vscodePlatformId}.vsix`;
94+
const packageFileName = getPackageName(packageJSON, vscodePlatformId);
9495
await install(platformInfo, packageJSON);
9596
await createPackageAsync(packageFileName, outputFolder, vscodePlatformId);
9697
}
@@ -104,14 +105,13 @@ async function install(platformInfo: PlatformInformation, packageJSON: any) {
104105
let runTimeDependencies = getRuntimeDependenciesPackages(packageJSON);
105106
let packagesToInstall = await getAbsolutePathPackagesToInstall(runTimeDependencies, platformInfo, codeExtensionPath);
106107
let provider = () => new NetworkSettings(undefined, undefined);
107-
if (!(await downloadAndInstallPackages(packagesToInstall, provider, eventStream, isValidDownload)))
108-
{
108+
if (!(await downloadAndInstallPackages(packagesToInstall, provider, eventStream, isValidDownload))) {
109109
throw Error("Failed to download package.");
110110
}
111111

112112
// The VSIX Format doesn't allow files that differ only by case. The Linux OmniSharp package had a lowercase version of these files ('.targets') targets from mono,
113113
// and an upper case ('.Targets') from Microsoft.Build.Runtime. Remove the lowercase versions.
114-
await del([ '.omnisharp/*/omnisharp/.msbuild/Current/Bin/Workflow.targets', '.omnisharp/*/omnisharp/.msbuild/Current/Bin/Workflow.VisualBasic.targets' ]);
114+
await del(['.omnisharp/*/omnisharp/.msbuild/Current/Bin/Workflow.targets', '.omnisharp/*/omnisharp/.msbuild/Current/Bin/Workflow.VisualBasic.targets']);
115115
}
116116

117117
/// Packaging (VSIX) Tasks

test/releaseTests/offlinePackage.test.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ import * as chai from 'chai';
77
import * as glob from 'glob-promise';
88
import * as path from 'path';
99
import { invokeNode } from './testAssets/testAssets';
10-
import { PlatformInformation } from '../../src/platform';
1110
import { TmpAsset, CreateTmpDir } from '../../src/CreateTmpAsset';
11+
import { getPackageName, offlinePackages } from '../../tasks/offlinePackagingTasks';
12+
import { getPackageJSON } from '../../tasks/packageJson';
13+
import { expect } from 'chai';
1214

1315
suite("Offline packaging of VSIX", function () {
1416
let vsixFiles: string[];
1517
this.timeout(1000000);
1618
let tmpDir: TmpAsset;
1719

20+
const packageJson = getPackageJSON();
21+
1822
suiteSetup(async () => {
1923
chai.should();
2024
tmpDir = await CreateTmpDir(true);
@@ -28,18 +32,19 @@ suite("Offline packaging of VSIX", function () {
2832
vsixFiles = glob.sync(path.join(tmpDir.name, '*.vsix'));
2933
});
3034

31-
test("Exactly 3 vsix files should be produced", () => {
32-
vsixFiles.length.should.be.equal(3, "the build should produce exactly 3 vsix files");
35+
test(`Exactly ${offlinePackages.length} vsix files should be produced`, () => {
36+
vsixFiles.length.should.be.equal(offlinePackages.length, `the build should produce exactly ${offlinePackages.length} vsix files`);
3337
});
3438

35-
[
36-
new PlatformInformation('win32', 'x86_64'),
37-
new PlatformInformation('darwin', 'x86_64'),
38-
new PlatformInformation('linux', 'x86_64')
39-
].forEach(element => {
40-
test(`Given Platform: ${element.platform} and Architecture: ${element.architecture}, the vsix file is created`, () => {
41-
vsixFiles.findIndex(elem => elem.indexOf(element.platform) != -1).should.not.be.equal(-1);
42-
vsixFiles.findIndex(elem => elem.indexOf(element.architecture) != -1).should.not.be.equal(-1);
39+
offlinePackages.forEach(packageInfo => {
40+
const platformInfo = packageInfo.platformInfo;
41+
const packageId = packageInfo.id;
42+
43+
test(`Given Platform: ${platformInfo.platform} and Architecture: ${platformInfo.architecture}, the vsix file is created`, () => {
44+
const expectedVsixName = getPackageName(packageJson, packageId);
45+
const vsixFile = vsixFiles.find(file => file.endsWith(expectedVsixName))
46+
expect(vsixFile, `offline packaging did not build package ${expectedVsixName}`)
47+
.to.not.be.null;
4348
});
4449
});
4550

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"module": "commonjs",
55
"outDir": "out",
66
"lib": [
7-
"es6"
7+
"ES2017"
88
],
99
"sourceMap": true,
1010
"moduleResolution": "node",

0 commit comments

Comments
 (0)