diff --git a/omnisharptest/omnisharpIntegrationTests/testAssets/BasicRazorApp2_1/.vscode/omnisharp_BasicRazorApp2_1.code-workspace b/omnisharptest/omnisharpIntegrationTests/testAssets/BasicRazorApp2_1/.vscode/omnisharp_BasicRazorApp2_1.code-workspace new file mode 100644 index 000000000..52264bf4f --- /dev/null +++ b/omnisharptest/omnisharpIntegrationTests/testAssets/BasicRazorApp2_1/.vscode/omnisharp_BasicRazorApp2_1.code-workspace @@ -0,0 +1,11 @@ +{ + "folders": [ + { + "path": ".." + } + ], + "settings": { + "dotnet.server.useOmnisharp": true, + "omnisharp.enableLspDriver": false + } +} \ No newline at end of file diff --git a/omnisharptest/omnisharpIntegrationTests/testAssets/BasicRazorApp2_1/.vscode/omnisharp_lsp_BasicRazorApp2_1.code-workspace b/omnisharptest/omnisharpIntegrationTests/testAssets/BasicRazorApp2_1/.vscode/omnisharp_lsp_BasicRazorApp2_1.code-workspace new file mode 100644 index 000000000..93e63a168 --- /dev/null +++ b/omnisharptest/omnisharpIntegrationTests/testAssets/BasicRazorApp2_1/.vscode/omnisharp_lsp_BasicRazorApp2_1.code-workspace @@ -0,0 +1,11 @@ +{ + "folders": [ + { + "path": ".." + } + ], + "settings": { + "dotnet.server.useOmnisharp": true, + "omnisharp.enableLspDriver": true + } +} \ No newline at end of file diff --git a/omnisharptest/omnisharpIntegrationTests/testAssets/BasicRazorApp2_1/.vscode/settings.json b/omnisharptest/omnisharpIntegrationTests/testAssets/BasicRazorApp2_1/.vscode/settings.json deleted file mode 100644 index 254a53272..000000000 --- a/omnisharptest/omnisharpIntegrationTests/testAssets/BasicRazorApp2_1/.vscode/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dotnet.server.useOmnisharp": true, - "omnisharp.enableLspDriver": false -} \ No newline at end of file diff --git a/omnisharptest/omnisharpIntegrationTests/testAssets/singleCsproj/.vscode/omnisharp_lsp_singleCsproj.code-workspace b/omnisharptest/omnisharpIntegrationTests/testAssets/singleCsproj/.vscode/omnisharp_lsp_singleCsproj.code-workspace new file mode 100644 index 000000000..d2bbe1696 --- /dev/null +++ b/omnisharptest/omnisharpIntegrationTests/testAssets/singleCsproj/.vscode/omnisharp_lsp_singleCsproj.code-workspace @@ -0,0 +1,13 @@ +{ + "folders": [ + { + "path": ".." + } + ], + "settings": { + "omnisharp.path": "latest", + "omnisharp.enableRoslynAnalyzers": true, + "omnisharp.enableLspDriver": true, + "dotnet.server.useOmnisharp": true + } +} \ No newline at end of file diff --git a/omnisharptest/omnisharpIntegrationTests/testAssets/singleCsproj/.vscode/omnisharp_singleCsproj.code-workspace b/omnisharptest/omnisharpIntegrationTests/testAssets/singleCsproj/.vscode/omnisharp_singleCsproj.code-workspace new file mode 100644 index 000000000..8bce15410 --- /dev/null +++ b/omnisharptest/omnisharpIntegrationTests/testAssets/singleCsproj/.vscode/omnisharp_singleCsproj.code-workspace @@ -0,0 +1,13 @@ +{ + "folders": [ + { + "path": ".." + } + ], + "settings": { + "omnisharp.path": "latest", + "omnisharp.enableRoslynAnalyzers": true, + "omnisharp.enableLspDriver": false, + "dotnet.server.useOmnisharp": true + } +} \ No newline at end of file diff --git a/omnisharptest/omnisharpIntegrationTests/testAssets/singleCsproj/.vscode/settings.json b/omnisharptest/omnisharpIntegrationTests/testAssets/singleCsproj/.vscode/settings.json deleted file mode 100644 index 6b4671406..000000000 --- a/omnisharptest/omnisharpIntegrationTests/testAssets/singleCsproj/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "omnisharp.path": "latest", - "omnisharp.enableRoslynAnalyzers": true, - "omnisharp.enableLspDriver": false, - "dotnet.server.useOmnisharp": true -} \ No newline at end of file diff --git a/omnisharptest/omnisharpIntegrationTests/testAssets/slnFilterWithCsproj/.vscode/omnisharp_lsp_slnFilterWithCsproj.code-workspace b/omnisharptest/omnisharpIntegrationTests/testAssets/slnFilterWithCsproj/.vscode/omnisharp_lsp_slnFilterWithCsproj.code-workspace new file mode 100644 index 000000000..3b81724d7 --- /dev/null +++ b/omnisharptest/omnisharpIntegrationTests/testAssets/slnFilterWithCsproj/.vscode/omnisharp_lsp_slnFilterWithCsproj.code-workspace @@ -0,0 +1,14 @@ +{ + "folders": [ + { + "path": ".." + } + ], + "settings": { + "omnisharp.defaultLaunchSolution": "SolutionFilter.slnf", + "omnisharp.path": "latest", + "omnisharp.enableRoslynAnalyzers": true, + "dotnet.server.useOmnisharp": true, + "omnisharp.enableLspDriver": true, + } +} diff --git a/omnisharptest/omnisharpIntegrationTests/testAssets/slnFilterWithCsproj/.vscode/omnisharp_slnFilterWithCsproj.code-workspace b/omnisharptest/omnisharpIntegrationTests/testAssets/slnFilterWithCsproj/.vscode/omnisharp_slnFilterWithCsproj.code-workspace new file mode 100644 index 000000000..2b4d5a258 --- /dev/null +++ b/omnisharptest/omnisharpIntegrationTests/testAssets/slnFilterWithCsproj/.vscode/omnisharp_slnFilterWithCsproj.code-workspace @@ -0,0 +1,14 @@ +{ + "folders": [ + { + "path": ".." + } + ], + "settings": { + "omnisharp.defaultLaunchSolution": "SolutionFilter.slnf", + "omnisharp.path": "latest", + "omnisharp.enableRoslynAnalyzers": true, + "dotnet.server.useOmnisharp": true, + "omnisharp.enableLspDriver": false + } +} diff --git a/omnisharptest/omnisharpIntegrationTests/testAssets/slnFilterWithCsproj/.vscode/settings.json b/omnisharptest/omnisharpIntegrationTests/testAssets/slnFilterWithCsproj/.vscode/settings.json deleted file mode 100644 index 3d88b3241..000000000 --- a/omnisharptest/omnisharpIntegrationTests/testAssets/slnFilterWithCsproj/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "omnisharp.defaultLaunchSolution": "SolutionFilter.slnf", - "omnisharp.path": "latest", - "omnisharp.enableRoslynAnalyzers": true, - "dotnet.server.useOmnisharp": true -} diff --git a/omnisharptest/omnisharpIntegrationTests/testAssets/slnWithCsproj/.vscode/omnisharp_lsp_slnWithCsproj.code-workspace b/omnisharptest/omnisharpIntegrationTests/testAssets/slnWithCsproj/.vscode/omnisharp_lsp_slnWithCsproj.code-workspace index 54c68a2d2..a2db107ff 100644 --- a/omnisharptest/omnisharpIntegrationTests/testAssets/slnWithCsproj/.vscode/omnisharp_lsp_slnWithCsproj.code-workspace +++ b/omnisharptest/omnisharpIntegrationTests/testAssets/slnWithCsproj/.vscode/omnisharp_lsp_slnWithCsproj.code-workspace @@ -9,6 +9,6 @@ "omnisharp.enableRoslynAnalyzers": true, "dotnet.server.useOmnisharp": true, "omnisharp.enableLspDriver": true, - "dotnet.defaultSolution": "b_SecondInOrder_SlnFile.sln", + "dotnet.defaultSolution": "b_SecondInOrder_SlnFile.sln" } } \ No newline at end of file diff --git a/omnisharptest/omnisharpIntegrationTests/testAssets/slnWithCsproj/.vscode/settings.json b/omnisharptest/omnisharpIntegrationTests/testAssets/slnWithCsproj/.vscode/settings.json deleted file mode 100644 index 19242112e..000000000 --- a/omnisharptest/omnisharpIntegrationTests/testAssets/slnWithCsproj/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "omnisharp.defaultLaunchSolution": "b_SecondInOrder_SlnFile.sln", - "omnisharp.path": "latest", - "omnisharp.enableRoslynAnalyzers": true, - "dotnet.server.useOmnisharp": true, -} \ No newline at end of file diff --git a/package.json b/package.json index 8c84f5879..1dad3cfc1 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "omnisharptest:integration:slnWithCsproj": "tsc -p ./ && gulp omnisharptest:integration:slnWithCsproj", "omnisharptest:integration:slnFilterWithCsproj": "tsc -p ./ && gulp omnisharptest:integration:slnFilterWithCsproj", "omnisharptest:artifacts": "tsc -p ./ && mocha out/omnisharptest/omnisharpArtifactTests/**/*.test.js", + "test:integration:slnWithCsproj": "tsc -p ./ && gulp test:integration:slnWithCsproj", "unpackage:vsix": "gulp vsix:release:unpackage", "updatePackageDependencies": "gulp updatePackageDependencies", "l10nDevGenerateXlf": "npx @vscode/l10n-dev generate-xlf ./package.nls.json ./l10n/bundle.l10n.json --outFile ./loc/vscode-csharp.xlf", diff --git a/tasks/projectPaths.ts b/tasks/projectPaths.ts index c9f9f60c8..94639aa18 100644 --- a/tasks/projectPaths.ts +++ b/tasks/projectPaths.ts @@ -19,9 +19,16 @@ export const languageServerDirectory = path.join(rootPath, '.roslyn'); export const codeExtensionPath = commandLineOptions.codeExtensionPath || rootPath; -export const testRootPath = path.join(rootPath, 'out', 'omnisharptest'); -export const featureTestRunnerPath = path.join(testRootPath, 'runFeatureTests.js'); +export const omnisharpTestRootPath = path.join(rootPath, 'out', 'omnisharptest'); +export const omnisharpFeatureTestRunnerPath = path.join(omnisharpTestRootPath, 'runFeatureTests.js'); +export const omnisharpTestAssetsRootPath = path.join( + rootPath, + 'omnisharptest', + 'omnisharpIntegrationTests', + 'testAssets' +); + +export const testRootPath = path.join(rootPath, 'out', 'test'); export const integrationTestRunnerPath = path.join(testRootPath, 'runIntegrationTests.js'); -export const testAssetsRootPath = path.join(rootPath, 'omnisharptest', 'omnisharpIntegrationTests', 'testAssets'); export const nodePath = path.join(process.env.NVM_BIN ? `${process.env.NVM_BIN}${path.sep}` : '', 'node'); diff --git a/tasks/testTasks.ts b/tasks/testTasks.ts index 94caadd24..e17b0a233 100644 --- a/tasks/testTasks.ts +++ b/tasks/testTasks.ts @@ -7,13 +7,14 @@ import * as gulp from 'gulp'; import * as path from 'path'; import { codeExtensionPath, - featureTestRunnerPath, - integrationTestRunnerPath, - jestPath, + omnisharpFeatureTestRunnerPath, mochaPath, rootPath, - testAssetsRootPath, + omnisharpTestAssetsRootPath, + omnisharpTestRootPath, testRootPath, + integrationTestRunnerPath, + jestPath, } from './projectPaths'; import spawnNode from './spawnNode'; @@ -21,12 +22,12 @@ gulp.task('omnisharptest:feature', async () => { const env = { OSVC_SUITE: 'omnisharpFeatureTests', CODE_EXTENSIONS_PATH: codeExtensionPath, - CODE_TESTS_PATH: path.join(testRootPath, 'omnisharpFeatureTests'), + CODE_TESTS_PATH: path.join(omnisharpTestRootPath, 'omnisharpFeatureTests'), CODE_WORKSPACE_ROOT: rootPath, CODE_DISABLE_EXTENSIONS: 'true', }; - const result = await spawnNode([featureTestRunnerPath], { env }); + const result = await spawnNode([omnisharpFeatureTestRunnerPath], { env }); if (result.code === null || result.code > 0) { // Ensure that gulp fails when tests fail @@ -60,8 +61,12 @@ gulp.task('omnisharp:jest:test', async () => { const projectNames = ['singleCsproj', 'slnWithCsproj', 'slnFilterWithCsproj', 'BasicRazorApp2_1']; for (const projectName of projectNames) { - gulp.task(`omnisharptest:integration:${projectName}:stdio`, async () => runIntegrationTest(projectName, 'stdio')); - gulp.task(`omnisharptest:integration:${projectName}:lsp`, async () => runIntegrationTest(projectName, 'lsp')); + gulp.task(`omnisharptest:integration:${projectName}:stdio`, async () => + runOmnisharpIntegrationTest(projectName, 'stdio') + ); + gulp.task(`omnisharptest:integration:${projectName}:lsp`, async () => + runOmnisharpIntegrationTest(projectName, 'lsp') + ); gulp.task( `omnisharptest:integration:${projectName}`, gulp.series(`omnisharptest:integration:${projectName}:stdio`, `omnisharptest:integration:${projectName}:lsp`) @@ -86,24 +91,63 @@ gulp.task( gulp.series('omnisharp:jest:test', 'omnisharptest:feature', 'omnisharptest:unit', 'omnisharptest:integration:stdio') ); +gulp.task('test:integration:slnWithCsproj', async () => runIntegrationTest('slnWithCsproj')); + gulp.task('test:unit', async () => { runJestTest(/unitTests.*\.ts/); }); gulp.task('test', gulp.series('test:unit')); -async function runIntegrationTest(testAssetName: string, engine: 'stdio' | 'lsp') { +async function runOmnisharpIntegrationTest(testAssetName: string, engine: 'stdio' | 'lsp') { + const workspaceFile = `omnisharp${engine === 'lsp' ? '_lsp' : ''}_${testAssetName}.code-workspace`; + const workspacePath = path.join(omnisharpTestAssetsRootPath, testAssetName, '.vscode', workspaceFile); + const codeTestsPath = path.join(omnisharpTestRootPath, 'omnisharpIntegrationTests'); + const env = { OSVC_SUITE: testAssetName, - CODE_TESTS_PATH: path.join(testRootPath, 'omnisharpIntegrationTests'), + CODE_TESTS_PATH: codeTestsPath, CODE_EXTENSIONS_PATH: codeExtensionPath, - CODE_TESTS_WORKSPACE: path.join(testAssetsRootPath, testAssetName), + CODE_TESTS_WORKSPACE: workspacePath, CODE_WORKSPACE_ROOT: rootPath, + EXTENSIONS_TESTS_PATH: path.join(codeTestsPath, 'index.js'), OMNISHARP_ENGINE: engine, OMNISHARP_LOCATION: process.env.OMNISHARP_LOCATION, CODE_DISABLE_EXTENSIONS: 'true', }; + const result = await spawnNode([integrationTestRunnerPath, '--enable-source-maps'], { + env, + cwd: rootPath, + }); + + if (result.code === null || result.code > 0) { + // Ensure that gulp fails when tests fail + throw new Error(`Exit code: ${result.code} Signal: ${result.signal}`); + } + + return result; +} + +async function runIntegrationTest(testAssetName: string) { + const workspacePath = path.join( + omnisharpTestAssetsRootPath, + testAssetName, + '.vscode', + `lsp_tools_host_${testAssetName}.code-workspace` + ); + const codeTestsPath = path.join(testRootPath, 'integrationTests'); + + const env = { + OSVC_SUITE: testAssetName, + CODE_TESTS_PATH: codeTestsPath, + CODE_EXTENSIONS_PATH: codeExtensionPath, + CODE_TESTS_WORKSPACE: workspacePath, + CODE_WORKSPACE_ROOT: rootPath, + EXTENSIONS_TESTS_PATH: path.join(codeTestsPath, 'index.js'), + CODE_DISABLE_EXTENSIONS: 'true', + }; + const result = await spawnNode([integrationTestRunnerPath, '--enable-source-maps'], { env, cwd: rootPath }); if (result.code === null || result.code > 0) { diff --git a/omnisharptest/runIntegrationTests.ts b/test/runIntegrationTests.ts similarity index 93% rename from omnisharptest/runIntegrationTests.ts rename to test/runIntegrationTests.ts index b48941919..f9ceb4696 100644 --- a/omnisharptest/runIntegrationTests.ts +++ b/test/runIntegrationTests.ts @@ -31,7 +31,12 @@ async function main() { // The path to the extension test runner script // Passed to --extensionTestsPath - const extensionTestsPath = path.resolve(__dirname, './omnisharpIntegrationTests/index'); + const extensionTestsPath = process.env.EXTENSIONS_TESTS_PATH; + + if (!extensionTestsPath) { + console.error('Empty extension tests path'); + process.exit(-1); + } // The integration tests expect that the workspace to run the // tests against is set in an environment variable.