Skip to content

Commit

Permalink
Move OmniSharp test code under the /test folder
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed Sep 7, 2024
1 parent 222fe7d commit 5a35b2e
Show file tree
Hide file tree
Showing 332 changed files with 625 additions and 275 deletions.
4 changes: 2 additions & 2 deletions .config/guardian/.gdnbaselines
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"d6ffb0614846153cf3cc5936d0444ed9eda6fe6854febb4c8ea59243c120b223": {
"signature": "d6ffb0614846153cf3cc5936d0444ed9eda6fe6854febb4c8ea59243c120b223",
"alternativeSignatures": [],
"target": "omnisharptest/omnisharpUnitTests/testAssets/private.pem",
"target": "test/omnisharp/omnisharpUnitTests/testAssets/private.pem",
"line": 1,
"memberOf": [
"default"
Expand All @@ -26,4 +26,4 @@
"justification": "This error is baselined with an expiration date of 180 days from 2024-06-27 21:44:58Z"
}
}
}
}
16 changes: 8 additions & 8 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
// 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",
"${workspaceRoot}/test/lsptoolshost/integrationTests/testAssets/slnWithCsproj/.vscode/lsp_tools_host_slnWithCsproj.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test/integrationTests"
"--extensionTestsPath=${workspaceRoot}/out/test/lsptoolshost/integrationTests"
],
"env": {
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
Expand All @@ -43,9 +43,9 @@
// 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/razorIntegrationTests/testAssets/BasicRazorApp2_1/.vscode/lsp_tools_host_BasicRazorApp2_1.code-workspace",
"${workspaceRoot}/test/razor/razorIntegrationTests/testAssets/BasicRazorApp2_1/.vscode/lsp_tools_host_BasicRazorApp2_1.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test/razorIntegrationTests"
"--extensionTestsPath=${workspaceRoot}/out/test/razor/razorIntegrationTests"
],
"env": {
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
Expand All @@ -66,9 +66,9 @@
// 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/${input:omnisharpAssetName}/.vscode/omnisharp_${input:omnisharpAssetName}.code-workspace",
"${workspaceRoot}/test/omnisharp/omnisharpIntegrationTests/testAssets/${input:omnisharpAssetName}/.vscode/omnisharp_${input:omnisharpAssetName}.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/omnisharptest/omnisharpIntegrationTests"
"--extensionTestsPath=${workspaceRoot}/out/test/omnisharp/omnisharpIntegrationTests"
],
"env": {
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
Expand All @@ -89,9 +89,9 @@
// 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/${input:omnisharpAssetName}/.vscode/omnisharp_lsp_${input:omnisharpAssetName}.code-workspace",
"${workspaceRoot}/test/omnisharp/omnisharpIntegrationTests/testAssets/${input:omnisharpAssetName}/.vscode/omnisharp_lsp_${input:omnisharpAssetName}.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/omnisharptest/omnisharpIntegrationTests"
"--extensionTestsPath=${workspaceRoot}/out/test/omnisharp/omnisharpIntegrationTests"
],
"env": {
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
Expand Down
1 change: 0 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ server/**
src/**
tasks/**
test/**
omnisharptest/**
__mocks__/**
jest.config.ts
baseJestConfig.ts
Expand Down
2 changes: 1 addition & 1 deletion __mocks__/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import * as vscodeAdapter from '../src/vscodeAdapter';
import { getFakeVsCode } from '../test/unitTests/fakes';
import { getFakeVsCode } from '../test/fakes';

// This module creates a manual mock for the vscode module for running in unit tests.
// Jest will automatically pick this up as it is in the __mocks__ directory next to node_modules.
Expand Down
14 changes: 7 additions & 7 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import type { Config } from 'jest';

const config: Config = {
projects: [
'<rootDir>/test/unitTests/jest.config.ts',
'<rootDir>/test/integrationTests/jest.config.ts',
'<rootDir>/test/razorIntegrationTests/jest.config.ts',
'<rootDir>/test/razorTests/jest.config.ts',
'<rootDir>/test/artifactTests/jest.config.ts',
'<rootDir>/omnisharptest/omnisharpUnitTests/jest.config.ts',
'<rootDir>/omnisharptest/omnisharpIntegrationTests/jest.config.ts',
'<rootDir>/test/lsptoolshost/artifactTests/jest.config.ts',
'<rootDir>/test/lsptoolshost/integrationTests/jest.config.ts',
'<rootDir>/test/lsptoolshost/unitTests/jest.config.ts',
'<rootDir>/test/omnisharp/omnisharpIntegrationTests/jest.config.ts',
'<rootDir>/test/omnisharp/omnisharpUnitTests/jest.config.ts',
'<rootDir>/test/razor/razorIntegrationTests/jest.config.ts',
'<rootDir>/test/razor/razorTests/jest.config.ts',
],
// Reporters are a global jest configuration property and cannot be set in the project jest config.
// This configuration will create a 'junit.xml' file in the output directory, no matter which test project is running.
Expand Down
22 changes: 15 additions & 7 deletions tasks/testTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { codeExtensionPath, rootPath, outPath } from './projectPaths';
import spawnNode from './spawnNode';
import * as jest from 'jest';
import { Config } from '@jest/types';
import { jestOmniSharpUnitTestProjectName } from '../omnisharptest/omnisharpUnitTests/jest.config';
import { jestUnitTestProjectName } from '../test/unitTests/jest.config';
import { razorTestProjectName } from '../test/razorTests/jest.config';
import { jestArtifactTestsProjectName } from '../test/artifactTests/jest.config';
import { jestOmniSharpUnitTestProjectName } from '../test/omnisharp/omnisharpUnitTests/jest.config';
import { jestUnitTestProjectName } from '../test/lsptoolshost/unitTests/jest.config';
import { razorTestProjectName } from '../test/razor/razorTests/jest.config';
import { jestArtifactTestsProjectName } from '../test/lsptoolshost/artifactTests/jest.config';

gulp.task('test:razor', async () => {
runJestTest(razorTestProjectName);
Expand All @@ -22,7 +22,11 @@ gulp.task('test:razor', async () => {
const razorIntegrationTestProjects = ['BasicRazorApp2_1'];
for (const projectName of razorIntegrationTestProjects) {
gulp.task(`test:razorintegration:${projectName}`, async () =>
runIntegrationTest(projectName, 'razorIntegrationTests', `Razor Test Integration ${projectName}`)
runIntegrationTest(
projectName,
path.join('razor', 'razorIntegrationTests'),
`Razor Test Integration ${projectName}`
)
);
}

Expand Down Expand Up @@ -76,7 +80,11 @@ gulp.task('test:unit', async () => {
const integrationTestProjects = ['slnWithCsproj'];
for (const projectName of integrationTestProjects) {
gulp.task(`test:integration:${projectName}`, async () =>
runIntegrationTest(projectName, 'integrationTests', `Test Integration ${projectName}`)
runIntegrationTest(
projectName,
path.join('lsptoolshost', 'integrationTests'),
`Test Integration ${projectName}`
)
);
}

Expand All @@ -89,7 +97,7 @@ gulp.task('test', gulp.series('test:unit', 'test:integration', 'test:razor', 'te

async function runOmnisharpJestIntegrationTest(testAssetName: string, engine: 'stdio' | 'lsp', suiteName: string) {
const workspaceFile = `omnisharp${engine === 'lsp' ? '_lsp' : ''}_${testAssetName}.code-workspace`;
const testFolder = path.join('omnisharptest', 'omnisharpIntegrationTests');
const testFolder = path.join('test', 'omnisharp', 'omnisharpIntegrationTests');

const env = {
OSVC_SUITE: testAssetName,
Expand Down
12 changes: 6 additions & 6 deletions test/unitTests/fakes.ts → test/fakes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as vscode from '../../src/vscodeAdapter';
import * as protocol from '../../src/omnisharp/protocol';
import { ITelemetryReporter } from '../../src/shared/telemetryReporter';
import { MSBuildDiagnosticsMessage } from '../../src/omnisharp/protocol';
import * as vscode from '../src/vscodeAdapter';
import * as protocol from '../src/omnisharp/protocol';
import { ITelemetryReporter } from '../src/shared/telemetryReporter';
import { MSBuildDiagnosticsMessage } from '../src/omnisharp/protocol';
import {
OmnisharpServerMsBuildProjectDiagnostics,
OmnisharpServerOnError,
OmnisharpServerUnresolvedDependencies,
WorkspaceInformationUpdated,
} from '../../src/omnisharp/loggingEvents';
import * as vscodeAdapter from '../../src/vscodeAdapter';
} from '../src/omnisharp/loggingEvents';
import * as vscodeAdapter from '../src/vscodeAdapter';

export const getNullChannel = (): vscode.OutputChannel => {
const returnChannel: vscode.OutputChannel = {
Expand Down
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 type { Config } from 'jest';
import { baseProjectConfig } from '../../baseJestConfig';
import { baseProjectConfig } from '../../../baseJestConfig';

export const jestArtifactTestsProjectName = 'Artifact Tests';

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as vscode from 'vscode';
import { describe, test, expect, beforeAll, afterAll, beforeEach, afterEach } from '@jest/globals';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import { AnalysisSetting, BuildDiagnosticsService } from '../../src/lsptoolshost/buildDiagnosticsService';
import { AnalysisSetting, BuildDiagnosticsService } from '../../../src/lsptoolshost/buildDiagnosticsService';
import * as integrationHelpers from './integrationHelpers';
import path = require('path');
describe(`Build and live diagnostics dedupe ${testAssetWorkspace.description}`, () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as vscode from 'vscode';
import { describe, test, beforeAll, afterAll, expect, beforeEach, afterEach } from '@jest/globals';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import { AnalysisSetting } from '../../src/lsptoolshost/buildDiagnosticsService';
import { AnalysisSetting } from '../../../src/lsptoolshost/buildDiagnosticsService';
import * as integrationHelpers from './integrationHelpers';
import path = require('path');
import { getCode, setBackgroundAnalysisScopes, waitForExpectedDiagnostics } from './diagnosticsHelpers';
Expand Down
File renamed without changes.
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 { runIntegrationTests } from '../runIntegrationTests';
import { runIntegrationTests } from '../../runIntegrationTests';
import { jestIntegrationTestProjectName } from './jest.config';

export async function run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import * as vscode from 'vscode';
import * as path from 'path';
import { CSharpExtensionExports } from '../../src/csharpExtensionExports';
import { CSharpExtensionExports } from '../../../src/csharpExtensionExports';
import { existsSync } from 'fs';
import { ServerState } from '../../src/lsptoolshost/serverStateChange';
import { ServerState } from '../../../src/lsptoolshost/serverStateChange';
import testAssetWorkspace from './testAssets/testAssetWorkspace';

export async function activateCSharpExtension(): Promise<void> {
Expand Down
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 type { Config } from 'jest';
import { baseProjectConfig } from '../../baseJestConfig';
import { baseProjectConfig } from '../../../baseJestConfig';

export const jestIntegrationTestProjectName = 'Integration Tests';

Expand All @@ -14,8 +14,8 @@ const integrationTestConfig: Config = {
...baseProjectConfig,
displayName: jestIntegrationTestProjectName,
roots: ['<rootDir>'],
testEnvironment: '<rootDir>/jestSetup/vsCodeEnvironment.ts',
setupFilesAfterEnv: ['<rootDir>/jestSetup/vsCodeFramework.ts'],
testEnvironment: '<rootDir>/../../vsCodeEnvironment.ts',
setupFilesAfterEnv: ['<rootDir>/../../vsCodeFramework.ts'],
};

export default integrationTestConfig;
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import * as fs from 'async-file';
import * as path from 'path';
import * as vscode from 'vscode';
import spawnGit from '../../../test/integrationTests/testAssets/spawnGit';
import { execChildProcess } from '../../../src/common';
import spawnGit from './spawnGit';
import { execChildProcess } from '../../../../src/common';

export class TestAssetProject {
constructor(project: ITestAssetProject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
getCodeLensesAsync,
openFileInWorkspaceAsync,
} from './integrationHelpers';
import { TestProgress } from '../../src/lsptoolshost/roslynProtocol';
import { TestProgress } from '../../../src/lsptoolshost/roslynProtocol';

describe(`[${testAssetWorkspace.description}] Test Unit Testing`, () => {
beforeAll(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as vscode from 'vscode';
import { describe, test, expect, beforeAll, afterAll } from '@jest/globals';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import { AnalysisSetting } from '../../src/lsptoolshost/buildDiagnosticsService';
import { AnalysisSetting } from '../../../src/lsptoolshost/buildDiagnosticsService';
import * as integrationHelpers from './integrationHelpers';
import { getCode, setBackgroundAnalysisScopes, waitForExpectedDiagnostics } from './diagnosticsHelpers';
describe(`[${testAssetWorkspace.description}] Test diagnostics`, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { readFileSync } from 'fs';
import { convertServerOptionNameToClientConfigurationName } from '../../src/lsptoolshost/optionNameConverter';
import { convertServerOptionNameToClientConfigurationName } from '../../../src/lsptoolshost/optionNameConverter';
import { describe, test, expect } from '@jest/globals';

const editorBehaviorSection = 1;
Expand Down
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 type { Config } from 'jest';
import { baseProjectConfig } from '../../baseJestConfig';
import { baseProjectConfig } from '../../../baseJestConfig';

export const jestUnitTestProjectName = 'Unit Tests';

Expand All @@ -19,7 +19,7 @@ const unitTestConfig: Config = {
// Specify jest to only run tests in jest folders.
// We also have to include the __mocks__ folder. That folder must be next to node_modules so we can't move it,
// but if we specify roots, jest won't automatically pick it up. So we have to specify it here.
roots: ['<rootDir>', '<rootDir>../../__mocks__'],
roots: ['<rootDir>', '<rootDir>../../../__mocks__'],
};

export default unitTestConfig;
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 { tolerantParse } from '../../src/json';
import { tolerantParse } from '../../../src/json';
import { describe, test, expect } from '@jest/globals';

describe('JSON', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import { timeout } from 'rxjs/operators';
import { from as observableFrom, Subject, BehaviorSubject } from 'rxjs';
import { registerLanguageServerOptionChanges } from '../../src/lsptoolshost/optionChanges';
import { registerLanguageServerOptionChanges } from '../../../src/lsptoolshost/optionChanges';

import { describe, beforeEach, test, expect } from '@jest/globals';
import * as vscode from 'vscode';
import { getVSCodeWithConfig, updateConfig } from './fakes';
import { getVSCodeWithConfig, updateConfig } from '../../fakes';

describe('Option changes observer', () => {
let doClickOk: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { readFileSync } from 'fs';
import { migrateOptions } from '../../src/shared/migrateOptions';
import { migrateOptions } from '../../../src/shared/migrateOptions';
import { describe, test, expect } from '@jest/globals';

describe('Migrate configuration should in package.json', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as vscode from 'vscode';
import { activateCSharpExtension, describeIfNotRazorOrGenerator } from './integrationHelpers';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';

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

function setLimit(to: number | null) {
const csharpConfig = vscode.workspace.getConfiguration('csharp');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { expect, test, beforeAll, afterAll } from '@jest/globals';
import OmniSharpCompletionProvider from '../../src/omnisharp/features/completionProvider';
import OmniSharpCompletionProvider from '../../../src/omnisharp/features/completionProvider';
import * as vscode from 'vscode';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';
import * as path from 'path';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { expect, test, beforeAll, afterAll } from '@jest/globals';
import * as vscode from 'vscode';
import OmniSharpDefinitionProvider from '../../src/omnisharp/features/definitionProvider';
import OmniSharpDefinitionProvider from '../../../src/omnisharp/features/definitionProvider';
import * as path from 'path';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';
import { activateCSharpExtension, describeIfNotRazorOrGenerator, restartOmniSharpServer } from './integrationHelpers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import * as vscode from 'vscode';
import * as path from 'path';
import { activateCSharpExtension, describeIfSlnWithCsProj } from './integrationHelpers';
import testAssetWorkspace from './testAssets/activeTestAssetWorkspace';
import { EventStream } from '../../src/eventStream';
import { EventType } from '../../src/omnisharp/eventType';
import { OmnisharpRequestMessage } from '../../src/omnisharp/loggingEvents';
import { V2 } from '../../src/omnisharp/protocol';
import { EventStream } from '../../../src/eventStream';
import { EventType } from '../../../src/omnisharp/eventType';
import { OmnisharpRequestMessage } from '../../../src/omnisharp/loggingEvents';
import { V2 } from '../../../src/omnisharp/protocol';
import { isNotNull } from '../testUtil';

// These tests only run on the slnWithCsproj solution
Expand Down
Loading

0 comments on commit 5a35b2e

Please sign in to comment.