Skip to content

Commit

Permalink
Merge pull request #6271 from dibarbet/jest_test_test
Browse files Browse the repository at this point in the history
Add unit test integration tests + cleanup test running
  • Loading branch information
dibarbet authored Sep 7, 2023
2 parents 1a624d3 + f584cc3 commit 06b7116
Show file tree
Hide file tree
Showing 159 changed files with 1,028 additions and 811 deletions.
67 changes: 36 additions & 31 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,34 @@
],
"preLaunchTask": "buildDev"
},
{
"name": "Launch Current File slnWithCsproj Integration Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
// Create a temp profile that has no extensions / user settings.
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
"--profile-temp",
"${workspaceRoot}/test/integrationTests/testAssets/slnWithCsproj/.vscode/lsp_tools_host_slnWithCsproj.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test/integrationTests",
],
"env": {
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
"TEST_FILE_FILTER": "${file}"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/dist/*.js",
"${workspaceRoot}/out/test/**/*.js"
],
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
"!**/node_modules/**"
],
"preLaunchTask": "buildDev"
},
{
"type": "node",
"request": "launch",
Expand Down Expand Up @@ -66,7 +94,7 @@
// Create a temp profile that has no extensions / user settings.
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
"--profile-temp",
"${workspaceRoot}/omnisharptest/omnisharpIntegrationTests/testAssets/singleCsproj",
"${workspaceRoot}/test/integrationTests/testAssets/singleCsproj/.vscode/omnisharp_singleCsproj.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/omnisharptest/omnisharpIntegrationTests"
],
Expand All @@ -90,7 +118,7 @@
// Create a temp profile that has no extensions / user settings.
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
"--profile-temp",
"${workspaceRoot}/omnisharptest/omnisharpIntegrationTests/testAssets/BasicRazorApp2_1",
"${workspaceRoot}/test/integrationTests/testAssets/BasicRazorApp2_1",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/omnisharptest/omnisharpIntegrationTests"
],
Expand All @@ -108,7 +136,7 @@
// Create a temp profile that has no extensions / user settings.
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
"--profile-temp",
"${workspaceRoot}/omnisharptest/omnisharpIntegrationTests/testAssets/slnWithCsproj/.vscode/omnisharp_slnWithCsproj.code-workspace",
"${workspaceRoot}/test/integrationTests/testAssets/slnWithCsproj/.vscode/omnisharp_slnWithCsproj.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/omnisharptest/omnisharpIntegrationTests"
],
Expand All @@ -123,29 +151,6 @@
],
"preLaunchTask": "buildDev"
},
{
"name": "LSP Tools Host: Launch slnWithCsproj Workspace Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
// Create a temp profile that has no extensions / user settings.
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
"--profile-temp",
"${workspaceRoot}/omnisharptest/omnisharpIntegrationTests/testAssets/slnWithCsproj/.vscode/lsp_tools_host_slnWithCsproj.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test/integrationTests",
],
"env": {
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/dist/*.js",
"${workspaceRoot}/out/test/**/*.js"
],
"preLaunchTask": "buildDev"
},
{
"name": "Omnisharp: Launch singleCsproj Workspace Tests [LSP]",
"type": "extensionHost",
Expand All @@ -155,7 +160,7 @@
// Create a temp profile that has no extensions / user settings.
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
"--profile-temp",
"${workspaceRoot}/omnisharptest/omnisharpIntegrationTests/testAssets/slnWithCsproj/.vscode/omnisharp_lsp_slnWithCsproj.code-workspace",
"${workspaceRoot}/test/integrationTests/testAssets/singleCsproj/.vscode/omnisharp_lsp_singleCsproj.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/omnisharptest/omnisharpIntegrationTests"
],
Expand All @@ -179,7 +184,7 @@
// Create a temp profile that has no extensions / user settings.
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
"--profile-temp",
"${workspaceRoot}/omnisharptest/omnisharpIntegrationTests/testAssets/BasicRazorApp2_1",
"${workspaceRoot}/test/integrationTests/testAssets/BasicRazorApp2_1",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/omnisharptest/omnisharpIntegrationTests"
],
Expand All @@ -197,7 +202,7 @@
// Create a temp profile that has no extensions / user settings.
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
"--profile-temp",
"${workspaceRoot}/omnisharptest/omnisharpIntegrationTests/testAssets/slnWithCsproj/.vscode/omnisharp_lsp_slnWithCsproj.code-workspace",
"${workspaceRoot}/test/integrationTests/testAssets/slnWithCsproj/.vscode/omnisharp_lsp_slnWithCsproj.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/omnisharptest/omnisharpIntegrationTests"
],
Expand All @@ -221,7 +226,7 @@
// Create a temp profile that has no extensions / user settings.
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
"--profile-temp",
"${workspaceRoot}/omnisharptest/omnisharpIntegrationTests/testAssets/slnFilterWithCsproj",
"${workspaceRoot}/test/integrationTests/testAssets/slnFilterWithCsproj",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/omnisharptest/omnisharpIntegrationTests"
],
Expand All @@ -245,7 +250,7 @@
// Create a temp profile that has no extensions / user settings.
// This allows us to only have the C# extension + the dotnet runtime installer extension dependency.
"--profile-temp",
"${workspaceRoot}/omnisharptest/omnisharpIntegrationTests/testAssets/slnWithGenerator",
"${workspaceRoot}/test/integrationTests/testAssets/slnWithGenerator",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/omnisharptest/omnisharpIntegrationTests"
],
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
"omnisharp.autoStart": false,
"editor.formatOnSave": false,
"eslint.lintTask.enable": true,
"dotnet.defaultSolution": "disable"
"dotnet.defaultSolution": "disable",
"jest.autoRun": "off"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as vscode from 'vscode';
import { expect, should } from 'chai';
import * as path from 'path';
import { activateCSharpExtension, isRazorWorkspace, isSlnWithGenerator } from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';

import { Advisor } from '../../src/features/diagnosticsProvider';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as vscode from 'vscode';

import { should, expect } from 'chai';
import { activateCSharpExtension, isRazorWorkspace, isSlnWithGenerator } from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';
import * as path from 'path';
import { assertWithPoll } from './poll';
import { isNotNull } from '../testUtil';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as path from 'path';

import { should, expect } from 'chai';
import { activateCSharpExtension, isSlnWithCsproj, isSlnWithGenerator } from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';
import { isNotNull } from '../testUtil';

suite(`CodeLensProvider: ${testAssetWorkspace.description}`, function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import OmniSharpCompletionProvider from '../../src/features/completionProvider';
import * as vscode from 'vscode';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';
import * as path from 'path';
import { use, expect, should } from 'chai';
import * as chaiArray from 'chai-arrays';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as vscode from 'vscode';
import OmniSharpDefinitionProvider from '../../src/features/definitionProvider';
import * as path from 'path';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';
import { expect, should } from 'chai';
import {
activateCSharpExtension,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
isSlnWithGenerator,
restartOmniSharpServer,
} from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';
import { poll, assertWithPoll, pollDoesNotHappen } from './poll';
import { isNotNull } from '../testUtil';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as path from 'path';

import { should, expect } from 'chai';
import * as integrationHelpers from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';

suite(`DocumentSymbolProvider: ${testAssetWorkspace.description}`, function () {
let fileUri: vscode.Uri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as chaiArray from 'chai-arrays';
import * as vscode from 'vscode';
import * as path from 'path';
import { isRazorWorkspace, isSlnWithGenerator } from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';

use(chaiArray);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as path from 'path';

import { should, expect } from 'chai';
import { activateCSharpExtension, isSlnWithCsproj } from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';
import { EventStream } from '../../src/eventStream';
import { EventType } from '../../src/omnisharp/eventType';
import { OmnisharpRequestMessage } from '../../src/omnisharp/loggingEvents';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as path from 'path';

import { should, expect } from 'chai';
import { activateCSharpExtension, isRazorWorkspace, isSlnWithGenerator } from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';

export type Test = 'a' | 'b' | ['c', any];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as vscode from 'vscode';
import OmniSharpImplementationProvider from '../../src/features/implementationProvider';
import * as path from 'path';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';
import { expect, should } from 'chai';
import { activateCSharpExtension, isRazorWorkspace, isSlnWithGenerator } from './integrationHelpers';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
isSlnWithGenerator,
restartOmniSharpServer,
} from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';
import * as path from 'path';
import { InlayHint, LinePositionSpanTextChange } from '../../src/omnisharp/protocol';
import { isNotNull } from '../testUtil';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import * as vscode from 'vscode';
import * as path from 'path';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';
import { expect, should } from 'chai';
import { activateCSharpExtension, isRazorWorkspace, isSlnWithGenerator } from './integrationHelpers';
import { LanguageMiddleware, LanguageMiddlewareFeature } from '../../src/omnisharp/languageMiddlewareFeature';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as vscode from 'vscode';

import { should, expect } from 'chai';
import { activateCSharpExtension, isRazorWorkspace, isSlnWithGenerator } from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';
import { poll } from './poll';
import { isNotNull } from '../testUtil';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as path from 'path';

import { should, expect } from 'chai';
import { activateCSharpExtension, isRazorWorkspace, isSlnWithGenerator } from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';
import { poll, assertWithPoll } from './poll';
import { EventStream } from '../../src/eventStream';
import { EventType } from '../../src/omnisharp/eventType';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as vscode from 'vscode';
import OmniSharpReferenceProvider from '../../src/features/referenceProvider';
import * as path from 'path';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';
import { expect, should } from 'chai';
import { activateCSharpExtension, isRazorWorkspace, isSlnWithGenerator } from './integrationHelpers';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as path from 'path';

import { should, assert } from 'chai';
import { activateCSharpExtension, isRazorWorkspace, isSlnWithGenerator } from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';

interface ExpectedToken {
startLine: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as path from 'path';

import { expect, should } from 'chai';
import { activateCSharpExtension, isRazorWorkspace, isSlnWithGenerator } from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';

suite(`SignatureHelp: ${testAssetWorkspace.description}`, function () {
let fileUri: vscode.Uri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as path from 'path';
import OmniSharpDefinitionProvider from '../../src/features/definitionProvider';
import { activateCSharpExtension, isSlnWithGenerator, restartOmniSharpServer } from './integrationHelpers';
import { assertWithPoll, sleep } from './poll';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';

suite(`${OmniSharpDefinitionProvider.name}: ${testAssetWorkspace.description}`, () => {
let fileUri: vscode.Uri;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as path from 'path';
import * as vscode from 'vscode';

import { ITestAssetWorkspace } from '../../../test/integrationTests/testAssets/testAssets';

import singleCsproj from '../../../test/integrationTests/testAssets/singleCsproj';
import slnWithCsproj from '../../../test/integrationTests/testAssets/slnWithCsproj';
import slnFilterWithCsproj from '../../../test/integrationTests/testAssets/slnFilterWithCsproj';
import BasicRazorApp2_1 from '../../../test/integrationTests/testAssets/basicRazorApp21';
import slnWithGenerator from '../../../test/integrationTests/testAssets/slnWithGenerator';
import { OmnisharpTestAssetWorkspace } from './omnisharpTestAssetWorkspace';

const testAssetWorkspaces: { [x: string]: ITestAssetWorkspace } = {
singleCsproj,
slnWithCsproj,
slnFilterWithCsproj,
BasicRazorApp2_1,
slnWithGenerator,
};

const workspaceName = vscode.workspace.workspaceFolders![0].uri.fsPath.split(path.sep).pop();

const activeTestAssetWorkspace = new OmnisharpTestAssetWorkspace(testAssetWorkspaces[workspaceName!]);

export default activeTestAssetWorkspace;
Loading

0 comments on commit 06b7116

Please sign in to comment.