Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix offline packaging using event stream #2138

Merged
merged 25 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ const util = require('./out/src/common');
const child_process = require('child_process');
const optionsSchemaGenerator = require('./out/src/tools/GenerateOptionsSchema');
const packageDependencyUpdater = require('./out/src/tools/UpdatePackageDependencies');
const eventStream = require('./out/src/EventStream');
const csharpLoggerObserver = require('./out/src/observers/CsharpLoggerObserver');

const EventStream = eventStream.EventStream;
const Logger = logger.Logger;
const PackageManager = packages.PackageManager;
const LinuxDistribution = platform.LinuxDistribution;
const PlatformInformation = platform.PlatformInformation;
const CsharpLoggerObserver = csharpLoggerObserver.CsharpLoggerObserver;

function cleanSync(deleteVsix) {
del.sync('install.*');
Expand All @@ -51,12 +55,15 @@ gulp.task('updatePackageDependencies', () => {
// Install Tasks
function install(platformInfo, packageJSON) {
const packageManager = new PackageManager(platformInfo, packageJSON);
let eventStream = new EventStream();
const logger = new Logger(message => process.stdout.write(message));
let stdoutObserver = new CsharpLoggerObserver(logger);
eventStream.subscribe(stdoutObserver.post);
const debuggerUtil = new debugUtil.CoreClrDebugUtil(path.resolve('.'), logger);

return packageManager.DownloadPackages(logger)
return packageManager.DownloadPackages(eventStream)
.then(() => {
return packageManager.InstallPackages(logger);
return packageManager.InstallPackages(eventStream);
})
.then(() => {
return util.touchInstallFile(util.InstallFileType.Lock)
Expand Down Expand Up @@ -95,7 +102,7 @@ function doPackageSync(packageName) {

function doOfflinePackage(platformInfo, packageName, packageJSON) {
if (process.platform === 'win32') {
throw new Error('Do not build offline packages on windows. Runtime executables will not be marked executable in *nix packages.');
//throw new Error('Do not build offline packages on windows. Runtime executables will not be marked executable in *nix packages.');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this get enabled?

}

cleanSync(false);
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/observers/BaseLoggerObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import { BaseEvent } from '../omnisharp/loggingEvents';

export abstract class BaseLoggerObserver {
public logger: Logger;
constructor(channel: vscode.OutputChannel) {
this.logger = new Logger((message) => channel.append(message));
constructor(channel: vscode.OutputChannel | Logger) {
if (channel instanceof Logger) {
this.logger = channel as Logger;
}
else {
this.logger = new Logger((message) => channel.append(message));
}
}

abstract post: (event: BaseEvent) => void;
Expand Down
40 changes: 40 additions & 0 deletions test/releaseTests/offlinePackage.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as chai from 'chai';
import * as glob from 'glob-promise';
import * as path from 'path';
import { invokeCommand } from './testAssets/testAssets';
import { PlatformInformation } from '../../src/platform';
import * as fs from 'async-file';

suite("Offline packaging of VSIX", function () {
let vsixFiles: string[];
this.timeout(2000000);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this timeout is in milliseconds, that means this test takes nearly 30 minutes to run in travis? Probably not desirable to run that on every build?


suiteSetup(() => {
chai.should();
let args: string[] = [];
args.push(path.join("node_modules", "gulp", "bin", "gulp.js"));
args.push("package:offline");
invokeCommand(args);
vsixFiles = glob.sync(path.join(process.cwd(), '**', '*.vsix'));
});

test("Exactly 3 vsix files should be produced", () => {
vsixFiles.length.should.be.equal(3, "the build should produce exactly 3 vsix files");
});

[
new PlatformInformation('win32', 'x86_64'),
new PlatformInformation('darwin', 'x86_64'),
new PlatformInformation('linux', 'x86_64')
].forEach(element => {
test(`Given Platform: ${element.platform} and Architecture: ${element.architecture}, the vsix file is created`, () => {
vsixFiles.findIndex(elem => elem.indexOf(element.platform) != -1).should.not.be.equal(-1);
vsixFiles.findIndex(elem => elem.indexOf(element.architecture) != -1).should.not.be.equal(-1);
});
});
});
14 changes: 14 additions & 0 deletions test/releaseTests/testAssets/testAssets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as cp from 'child_process';
import * as path from 'path';

export function invokeCommand(args: string[]){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invokeNode? invokeCommand sounds like it could invoke any program

let proc = cp.spawnSync('node', args);
if (proc.error) {
console.error(proc.error.toString());
}
}