Skip to content

Commit

Permalink
Merge branch 'master' into env_file
Browse files Browse the repository at this point in the history
  • Loading branch information
gregg-miskelly authored Jul 23, 2018
2 parents 37760d5 + 16c5546 commit 3ab1f32
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 20 deletions.
17 changes: 10 additions & 7 deletions src/features/codeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ abstract class TestCodeLens extends OmniSharpCodeLens {
constructor(
range: protocol.V2.Range,
fileName: string,
public displayName: string,
public isTestContainer: boolean,
public testFramework: string,
public testMethodNames: string[]) {
Expand All @@ -53,23 +54,25 @@ class RunTestsCodeLens extends TestCodeLens {
constructor(
range: protocol.V2.Range,
fileName: string,
displayName: string,
isTestContainer: boolean,
testFramework: string,
testMethodNames: string[]) {

super(range, fileName, isTestContainer, testFramework, testMethodNames);
super(range, fileName, displayName, isTestContainer, testFramework, testMethodNames);
}
}

class DebugTestsCodeLens extends TestCodeLens {
constructor(
range: protocol.V2.Range,
fileName: string,
displayName: string,
isTestContainer: boolean,
testFramework: string,
testMethodNames: string[]) {

super(range, fileName, isTestContainer, testFramework, testMethodNames);
super(range, fileName, displayName, isTestContainer, testFramework, testMethodNames);
}
}

Expand Down Expand Up @@ -152,7 +155,7 @@ export default class OmniSharpCodeLensProvider extends AbstractProvider implemen
codeLens.command = {
title: pluralTitle,
command: pluralCommandName,
arguments: [codeLens.testMethodNames, codeLens.fileName, codeLens.testFramework]
arguments: [codeLens.displayName, codeLens.testMethodNames, codeLens.fileName, codeLens.testFramework]
};
}

Expand Down Expand Up @@ -188,8 +191,8 @@ function createCodeLensesForElement(element: Structure.CodeElement, fileName: st
let range = element.Ranges[SymbolRangeNames.Name];

if (range && testFramework && testMethodName) {
results.push(new RunTestsCodeLens(range, fileName, /*isTestContainer*/ false, testFramework, [testMethodName]));
results.push(new DebugTestsCodeLens(range, fileName, /*isTestContainer*/ false, testFramework, [testMethodName]));
results.push(new RunTestsCodeLens(range, fileName, element.DisplayName,/*isTestContainer*/ false, testFramework, [testMethodName]));
results.push(new DebugTestsCodeLens(range, fileName, element.DisplayName,/*isTestContainer*/ false, testFramework, [testMethodName]));
}
}
else if (isValidClassForTestCodeLens(element)) {
Expand All @@ -210,8 +213,8 @@ function createCodeLensesForElement(element: Structure.CodeElement, fileName: st
}
}

results.push(new RunTestsCodeLens(range, fileName, /*isTestContainer*/ true, testFramework, testMethodNames));
results.push(new DebugTestsCodeLens(range, fileName, /*isTestContainer*/ true, testFramework, testMethodNames));
results.push(new RunTestsCodeLens(range, fileName, element.DisplayName,/*isTestContainer*/ true, testFramework, testMethodNames));
results.push(new DebugTestsCodeLens(range, fileName, element.DisplayName,/*isTestContainer*/ true, testFramework, testMethodNames));
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/features/dotnetTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ export default class TestManager extends AbstractProvider {

let d4 = vscode.commands.registerCommand(
'dotnet.classTests.run',
async (methodsInClass, fileName, testFrameworkName) => this._runDotnetTestsInClass(methodsInClass, fileName, testFrameworkName));
async (className, methodsInClass, fileName, testFrameworkName) => this._runDotnetTestsInClass(className, methodsInClass, fileName, testFrameworkName));

let d5 = vscode.commands.registerCommand(
'dotnet.classTests.debug',
async (methodsInClass, fileName, testFrameworkName) => this._debugDotnetTestsInClass(methodsInClass, fileName, testFrameworkName));
async (className, methodsInClass, fileName, testFrameworkName) => this._debugDotnetTestsInClass(className, methodsInClass, fileName, testFrameworkName));

this._telemetryIntervalId = setInterval(() =>
this._reportTelemetry(), TelemetryReportingDelay);
Expand Down Expand Up @@ -164,10 +164,10 @@ export default class TestManager extends AbstractProvider {
}
}

private async _runDotnetTestsInClass(methodsInClass: string[], fileName: string, testFrameworkName: string) {
private async _runDotnetTestsInClass(className: string, methodsInClass: string[], fileName: string, testFrameworkName: string) {

//to do: try to get the class name here
this._eventStream.post(new DotNetTestsInClassRunStart());
this._eventStream.post(new DotNetTestsInClassRunStart(className));

const listener = this._server.onTestMessage(e => {
this._eventStream.post(new DotNetTestMessage(e.Message));
Expand Down Expand Up @@ -346,9 +346,9 @@ export default class TestManager extends AbstractProvider {
}
}

private async _debugDotnetTestsInClass(methodsToRun: string[], fileName: string, testFrameworkName: string) {
private async _debugDotnetTestsInClass(className: string, methodsToRun: string[], fileName: string, testFrameworkName: string) {

this._eventStream.post(new DotNetTestsInClassDebugStart());
this._eventStream.post(new DotNetTestsInClassDebugStart(className));

let { debugType, debugEventListener, targetFrameworkVersion } = await this._recordDebugAndGetDebugValues(fileName, testFrameworkName);

Expand Down
18 changes: 17 additions & 1 deletion src/observers/DotnetTestLoggerObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { BaseEvent, DotNetTestRunStart, DotNetTestMessage, ReportDotNetTestResults, DotNetTestDebugStart, DotNetTestDebugWarning, DotNetTestDebugProcessStart, DotNetTestDebugComplete } from "../omnisharp/loggingEvents";
import { BaseEvent, DotNetTestRunStart, DotNetTestMessage, ReportDotNetTestResults, DotNetTestDebugStart, DotNetTestDebugWarning, DotNetTestDebugProcessStart, DotNetTestDebugComplete, DotNetTestsInClassDebugStart, DotNetTestsInClassRunStart } from "../omnisharp/loggingEvents";
import { BaseLoggerObserver } from "./BaseLoggerObserver";
import * as protocol from '../omnisharp/protocol';

Expand Down Expand Up @@ -32,6 +32,12 @@ export default class DotNetTestLoggerObserver extends BaseLoggerObserver {
case DotNetTestDebugComplete.name:
this.logger.appendLine("Debugging complete.\n");
break;
case DotNetTestsInClassDebugStart.name:
this.handleDotnetTestsInClassDebugStart(<DotNetTestsInClassDebugStart>event);
break;
case DotNetTestsInClassRunStart.name:
this.handleDotnetTestsInClassRunStart(<DotNetTestsInClassRunStart>event);
break;
}
}

Expand All @@ -49,6 +55,16 @@ export default class DotNetTestLoggerObserver extends BaseLoggerObserver {
this.logger.appendLine('');
}

private handleDotnetTestsInClassDebugStart(event: DotNetTestsInClassDebugStart) {
this.logger.appendLine(`----- Debugging tests in class ${event.className} -----`);
this.logger.appendLine('');
}

private handleDotnetTestsInClassRunStart(event: DotNetTestsInClassRunStart): any {
this.logger.appendLine(`----- Running tests in class "${event.className}" -----`);
this.logger.appendLine('');
}

private handleDotNetTestDebugProcessStart(event: DotNetTestDebugProcessStart) {
this.logger.appendLine(`Started debugging process #${event.targetProcessId}.`);
}
Expand Down
11 changes: 9 additions & 2 deletions src/omnisharp/loggingEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ export class DotNetTestDebugProcessStart implements BaseEvent {
constructor(public targetProcessId: number) { }
}


export class DotNetTestsInClassRunStart implements BaseEvent {
constructor(public className: string) { }
}

export class DotNetTestsInClassDebugStart implements BaseEvent {
constructor(public className: string) { }
}

export class DebuggerPrerequisiteFailure extends EventWithMessage { }
export class DebuggerPrerequisiteWarning extends EventWithMessage { }
export class CommandDotNetRestoreProgress extends EventWithMessage { }
Expand Down Expand Up @@ -168,6 +177,4 @@ export class OmnisharpServerOnStop implements BaseEvent { }
export class OmnisharpServerOnStart implements BaseEvent { }
export class LatestBuildDownloadStart implements BaseEvent { }
export class OmnisharpRestart implements BaseEvent { }
export class DotNetTestsInClassRunStart implements BaseEvent { }
export class DotNetTestsInClassDebugStart implements BaseEvent { }
export class DotNetTestDebugComplete implements BaseEvent { }
34 changes: 34 additions & 0 deletions test/integrationTests/implementationProvider.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as vscode from "vscode";
import CSharpImplementationProvider from "../../src/features/implementationProvider";
import * as path from "path";
import testAssetWorkspace from "./testAssets/testAssetWorkspace";
import { expect } from "chai";
import { activateCSharpExtension } from './integrationHelpers';

suite(`${CSharpImplementationProvider.name}: ${testAssetWorkspace.description}`, () => {
let fileUri: vscode.Uri;

suiteSetup(async () => {
await testAssetWorkspace.restore();
await activateCSharpExtension();

let fileName = 'implementation.cs';
let projectDirectory = testAssetWorkspace.projects[0].projectDirectoryPath;
fileUri = vscode.Uri.file(path.join(projectDirectory, fileName));
await vscode.commands.executeCommand("vscode.open", fileUri);
});

suiteTeardown(async () => {
await testAssetWorkspace.cleanupWorkspace();
});

test("Returns the implementation", async() => {
let implementationList = <vscode.Location[]>(await vscode.commands.executeCommand("vscode.executeImplementationProvider", fileUri, new vscode.Position(4, 22)));
expect(implementationList.length).to.be.equal(2);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System;

namespace minimal
{
public class BaseClass {}
public class SomeClass : BaseClass {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System;

namespace minimal
{
public class BaseClass {}
public class SomeClass : BaseClass {}
}
4 changes: 2 additions & 2 deletions test/unitTests/logging/DotnetTestChannelObserver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ suite("DotnetTestChannelObserver", () => {
[
new DotNetTestRunStart("foo"),
new DotNetTestRunFailure("some failure"),
new DotNetTestsInClassRunStart(),
new DotNetTestsInClassRunStart("someclass"),
new DotNetTestDebugStart("foo"),
new DotNetTestsInClassDebugStart()
new DotNetTestsInClassDebugStart("someclass")
].forEach((event: BaseEvent) => {
test(`${event.constructor.name}: Channel is shown`, () => {
expect(hasShown).to.be.false;
Expand Down
15 changes: 13 additions & 2 deletions test/unitTests/logging/DotnetTestLoggerObserver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import * as chai from 'chai';
import { getNullChannel } from '../testAssets/Fakes';
import { EventWithMessage, DotNetTestDebugWarning, DotNetTestDebugStart, BaseEvent, DotNetTestRunStart, DotNetTestDebugProcessStart, DotNetTestMessage, DotNetTestDebugComplete, ReportDotNetTestResults } from '../../../src/omnisharp/loggingEvents';
import { EventWithMessage, DotNetTestDebugWarning, DotNetTestDebugStart, BaseEvent, DotNetTestRunStart, DotNetTestDebugProcessStart, DotNetTestMessage, DotNetTestDebugComplete, ReportDotNetTestResults, DotNetTestsInClassDebugStart, DotNetTestsInClassRunStart } from '../../../src/omnisharp/loggingEvents';
import DotNetTestLoggerObserver from '../../../src/observers/DotnetTestLoggerObserver';
import * as protocol from '../../../src/omnisharp/protocol';

Expand Down Expand Up @@ -42,7 +42,18 @@ suite(`${DotNetTestLoggerObserver.name}`, () => {
observer.post(event);
expect(appendedMessage).to.contain("foo");
});
});
});

[
new DotNetTestsInClassDebugStart("foo"),
new DotNetTestsInClassRunStart("foo")
].forEach((event: BaseEvent) => {
test(`${event.constructor.name}: Class name is logged`, () => {
expect(appendedMessage).to.be.empty;
observer.post(event);
expect(appendedMessage).to.contain("foo");
});
});

test(`${DotNetTestDebugProcessStart.name}: Target process id is logged`, () => {
let event = new DotNetTestDebugProcessStart(111);
Expand Down

0 comments on commit 3ab1f32

Please sign in to comment.