-
Notifications
You must be signed in to change notification settings - Fork 719
Add integration test for restore of file-based programs #8470
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
Draft
RikkiGibson
wants to merge
14
commits into
main
Choose a base branch
from
dev/rigibson/integration-test-restore
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+126
−24
Draft
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bd19287
add test resource
RikkiGibson 1305e21
WIP: Integration test for file-based programs restore scenario
RikkiGibson e0dea11
Merge remote-tracking branch 'origin/main' into dev/rigibson/integrat…
RikkiGibson 3458d52
add D.B.props
RikkiGibson d4b5997
cleanup
RikkiGibson f9be157
inspect details of notifications from server
RikkiGibson 5fd1d9c
use 'waitForAllAsyncOperationsAsync'
RikkiGibson 45e4d45
simplify
RikkiGibson fa315bc
fix lint errors
RikkiGibson 02e435c
Merge remote-tracking branch 'origin/main' into dev/rigibson/integrat…
RikkiGibson 0ef2931
WIP: bump roslyn version
RikkiGibson 5a32bb2
rekick CI after adding package to feeds
RikkiGibson ad92e62
fix lint errors
RikkiGibson 2239641
Merge branch 'dev/rigibson/integration-test-restore' of https://githu…
RikkiGibson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
test/lsptoolshost/integrationTests/restore.integration.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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 * as path from 'path'; | ||
import testAssetWorkspace from './testAssets/testAssetWorkspace'; | ||
import { | ||
activateCSharpExtension, | ||
closeAllEditorsAsync, | ||
getCompletionsAsync, | ||
openFileInWorkspaceAsync, | ||
revertActiveFile, | ||
sleep, | ||
waitForExpectedResult, | ||
} from './integrationHelpers'; | ||
import { describe, beforeAll, beforeEach, afterAll, test, expect, afterEach } from '@jest/globals'; | ||
import { CSharpExtensionExports } from '../../../src/csharpExtensionExports'; | ||
|
||
const timeout = 15*60*1000; | ||
|
||
describe(`Restore Tests`, () => { | ||
let exports: CSharpExtensionExports; | ||
|
||
beforeAll(async () => { | ||
exports = await activateCSharpExtension(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await openFileInWorkspaceAsync(path.join('src', 'scripts', 'app1.cs')); | ||
}); | ||
|
||
afterEach(async () => { | ||
await revertActiveFile(); | ||
await closeAllEditorsAsync(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await testAssetWorkspace.cleanupWorkspace(); | ||
}); | ||
|
||
test('Inserting package directive triggers a restore', async () => { | ||
await sleep(1); | ||
await vscode.window.activeTextEditor!.edit((editBuilder) => { | ||
editBuilder.insert(new vscode.Position(0, 0), '#:package [email protected]'); | ||
}); | ||
await vscode.window.activeTextEditor!.document.save(); | ||
|
||
let designTimeBuildFinished = false; | ||
exports.experimental.languageServerEvents.onProjectsRestored(() => { | ||
// Restore has finished. Now subscribe to the next design time build. | ||
// TODO: seems racy. | ||
exports.experimental.languageServerEvents.onProjectReloadCompleted(() => { | ||
designTimeBuildFinished = true; | ||
}); | ||
}); | ||
|
||
await waitForExpectedResult<boolean>( | ||
() => designTimeBuildFinished, | ||
timeout, | ||
100, | ||
(designTimeBuildFinished) => expect(designTimeBuildFinished).toBe(true) | ||
); | ||
|
||
// we restored, then completed a design-time build. | ||
const completionItems = await getCompletionsAsync(new vscode.Position(1, "using Newton".length), undefined, 10); | ||
|
||
expect(completionItems.items.map(item => item.label)).toContain("Newtonsoft"); | ||
}, timeout); | ||
}); |
4 changes: 4 additions & 0 deletions
4
test/lsptoolshost/integrationTests/testAssets/slnWithCsproj/src/scripts/app1.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
using Newton; | ||
|
||
Console.WriteLine("Hello World!"); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.