-
Notifications
You must be signed in to change notification settings - Fork 675
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
Add TaskProvider + integration test infrastructure #1826
Add TaskProvider + integration test infrastructure #1826
Conversation
@TheRealPiotrP, It will cover your contributions to all .NET Foundation-managed open source projects. |
@DustinCampbell @rchande the build failure's output is fairly sparse. A full test pass, however, does require that a project.json-supporting CLI be installed on the build agent. Do we know if 1.0.0-preview2-003231 is available on these agents? |
@TheRealPiotrP : That would not be available on these build agents and would need to be installed separately. |
Also, it looks like you need to sign the CLA? That's a bit weird. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good to me. Left a couple of questions.
src/omnisharp/extension.ts
Outdated
@@ -74,6 +76,8 @@ export function activate(context: vscode.ExtensionContext, reporter: TelemetryRe | |||
localDisposables.push(vscode.languages.registerCodeActionsProvider(documentSelector, codeActionProvider)); | |||
localDisposables.push(reportDiagnostics(server, reporter, advisor)); | |||
localDisposables.push(forwardChanges(server)); | |||
|
|||
taskProvider.activate(context, server); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taskProvider is disposable, should it get added to localDisposables
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
test/tasks.test.ts
Outdated
for (let task of buildTasks) { | ||
await vscode | ||
.commands | ||
.executeCommand('workbench.action.tasks.runTask', task.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @DustinCampbell for this little nugget :)
src/taskProvider.ts
Outdated
return; | ||
} | ||
|
||
taskProvider = vscode.workspace.registerTaskProvider('dotnet', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did the 'dotnet' constant come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's defined in package.json. I chose this constant fairly arbitrarily. Would we prefer c#
, csharp
, .net
?
src/taskProvider.ts
Outdated
|
||
let taskProvider: vscode.Disposable | undefined; | ||
|
||
export function activate(_context: vscode.ExtensionContext, server: OmniSharpServer): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the other features are registered by the extension defined in extension.ts
. Does the adapter pattern mean that we will have a separate extension class for every feature we want to test through the adapter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open for comment on this one. I prefer smaller, task-oriented units of code as I find them easier to understand, test, and modify.
@DustinCampbell regarding CLA I went through the flow again after being prompted yesterday. Do you know how to get the system to reconsider? |
Hi, I am closing and re-opening this PR to bump the CLA service. Sorry for the inconvenience! |
@WardenGnaw I believe this is due to the default tasks.json schema validator looking at the 0.1.0 schema instead of 2.0.0. The configuration here is the same as in the example: https://github.com/Microsoft/vscode-extension-samples/blob/master/task-provider-sample/src/extension.ts#L125. |
272863d
to
78a6e93
Compare
@rchande @DustinCampbell any guesses here? I finally got myself into a state where tests are running on CI, but O#-Roslyn is discovering 0 projects where I expected to see 1. Could this be a missing dependency issue? |
Out of curiosity, why are we working so hard to add support for project.json? Project.json projects are officially deprecated in C# for VS Code and the extension displays a warning to the user about migration whenever OmniSharp is launched in such a way that it loads a project.json project. I would propose that we don't bother with project.json and just target csproj. Also, note that project.json simply does not work on macOS 10.13 (High Sierra). Old .NET Core SDKs from the project.json error just segfault on 10.13. So, any project.json tests that require restore or build will fail on newer operating systems. I'm on High Sierra already. So, I wouldn't even be able to run tests like that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! However, I'd like to have a conversation about project.json. I'm not sure we need to expend effort implementing new features in support of that.
package.json
Outdated
} | ||
} | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent level looks different here. Was that intentional?
src/taskProvider.ts
Outdated
for (let project of workspaceInformation.DotNet.Projects) { | ||
tasks.push(provideBuildTask(project.Path, project.Path)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I wouldn't bother adding this feature for project.json, since the support is officially deprecated.
src/taskProvider.ts
Outdated
import { TaskRevealKind } from 'vscode'; | ||
|
||
export function activate(_context: vscode.ExtensionContext, server: OmniSharpServer): vscode.Disposable { | ||
if (!vscode.workspace.workspaceFolders) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use spaces rather than tabs. This is defined the repro's .vscode/settings.json file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why that wasn't respected... fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also added a tslint rule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
src/taskProvider.ts
Outdated
async function provideDotnetTasks(server: OmniSharpServer): Promise<vscode.Task[]> { | ||
let tasks: vscode.Task[] = []; | ||
|
||
let workspaceInformation = await serverUtils.requestWorkspaceInformation(server); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the first usage of await
! 😄
src/vscodeAdapter.ts
Outdated
@@ -0,0 +1,62 @@ | |||
import * as vscode from "vscode"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like this test infrastructure stuff should be in a separate folder rather than at the top-level src
. Should it be somewhere in the test
folder? Or, does this need to be included with the extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
8fbc18e
to
19bce75
Compare
@@ -7,6 +7,7 @@ | |||
"request": "launch", | |||
"runtimeExecutable": "${execPath}", | |||
"args": [ | |||
"${workspaceRoot}/test/integrationTests/testAssets/slnWithCsproj", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intend to change the default behavior of F5 on the extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I did. The extension typically opens in an arbitrary directory and I wanted to have it open in a directory that represents a 'kitchen sink'. I'm fine with reverting this, but found it useful for my own development.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Often, when reproducing an issue, I open the debuggee on a particular folder. Then, subsequent F5 will launch on the same directory allowing me to continue debugging. With this change, I'd need to either update launch.json first or open the folder on every debug session. I would definitely prefer not having this.
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yay tslint!
@@ -0,0 +1,40 @@ | |||
/*--------------------------------------------------------------------------------------------- | |||
* Copyright (c) Microsoft Corporation. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be in the 'src' folder or the 'test' folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. I created this directory structure:
- test
- unitTests
- integrationTests
- testAssets
src/taskProvider.ts
Outdated
import { TaskRevealKind } from 'vscode'; | ||
|
||
export function activate(_context: vscode.ExtensionContext, server: OmniSharpServer): vscode.Disposable { | ||
if (!vscode.workspace.workspaceFolders) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! However, it wasn't clear to me how we were avoiding running the project.json test. How does that work?
Also automatically selects the workspace for a given test run
9db4d66
to
a0e69a4
Compare
This PR aims to address #1820 and #1608.
I originally set out to fix #1608 by adding support for VS Code's Tasks API. However, I noticed that the existing build / test infrastructure did not enable me to write meaningful integration tests for this feature. Given that much of the code here is only verifiable in the context of VS Code I decided to make an infrastructure update prior to addressing the task at hand.
Test Infrastructure Changes
My strategy in updating the test infrastructure is two-fold. First, I wanted to be able to run integration tests in the context of representative workspaces. Second, I wanted to be able to access data shared with VS Code which is not subsequently queryable via VS Code API's. Here are the key components of the change:
Test Assets
I introduced a new top-level folder called
TestAssets
. Within this folder you will find three representative workspaces:These workspaces are accompanied by matching .ts files which describe, from a test expectations perspective, the contents of the workspaces.
launch.json updates
The launch.json has been updated to have test execution configurations for each of these workspaces. Selecting a given configuration will open the VS Code Test Host targetted at the specified TestAsset workspace. All of the tests running within that Test Host will then be interacting directly with the target workspace, allowing them to produce predictable results while exhibiting their ability to reason about that wokspace type. Note that in order to run through all test scenarios you must iterate through all available Test Configurations.
package.json updates
package.json was updated to allow cmd-line execution of each of the new Test Configurations. The base
npm test
command was updated to iterate through all three configurations, thereby ensuring that a single cmd-line invocation will execute all tests.Product Updates
Atop this test infrastructure I have implemented a basic task provider which intends to replicate the behavior of the original tasks.json implementation. Namely, it generates a
build
task for each identified project. The feature itself is fairly straightforward, though it does demand that we answer several questions:[ ] should we simultaneously disable tasks.json generation?
[ ] How do we want the tasks to appear in the VS Code UI? Currently they read
dotnet: build {project name}
. I would prefer to make thesedotnet: build {relative path to project file}
. However, I'd like to hear opinions on whether that relative path should be calculated by o#-vscode [by removing the workspace folder path from the fully qualified project path] or by o#-roslyn. @DustinCampbell looking for your insights here.[ ] How do we coordinate this PR with @WardenGnaw's #1801 work? I'm working with @WardenGnaw offline to figure this out.
[ ] Should we block on microsoft/vscode#33523 being available? Without that change we don't have a mechanism for users to provide additional task configuration data via tasks.json.