diff --git a/extensions/typescript-language-features/src/languageFeatures/jsDocCompletions.ts b/extensions/typescript-language-features/src/languageFeatures/jsDocCompletions.ts index 6e091af1692..40ff796ec46 100644 --- a/extensions/typescript-language-features/src/languageFeatures/jsDocCompletions.ts +++ b/extensions/typescript-language-features/src/languageFeatures/jsDocCompletions.ts @@ -95,9 +95,9 @@ export function templateToSnippet(template: string): vscode.SnippetString { // TODO: use append placeholder let snippetIndex = 1; template = template.replace(/\$/g, '\\$'); - template = template.replace(/^\s*(?=(\/|[ ]\*))/gm, ''); + template = template.replace(/^[ \t]*(?=(\/|[ ]\*))/gm, ''); template = template.replace(/^(\/\*\*\s*\*[ ]*)$/m, (x) => x + `\$0`); - template = template.replace(/\* @param([ ]\{\S+\})?\s+(\S+)\s*$/gm, (_param, type, post) => { + template = template.replace(/\* @param([ ]\{\S+\})?\s+(\S+)[ \t]$/gm, (_param, type, post) => { let out = '* @param '; if (type === ' {any}' || type === ' {*}') { out += `{\$\{${snippetIndex++}:*\}} `; diff --git a/extensions/typescript-language-features/src/test-all.ts b/extensions/typescript-language-features/src/test-all.ts new file mode 100644 index 00000000000..0057b8aa4a8 --- /dev/null +++ b/extensions/typescript-language-features/src/test-all.ts @@ -0,0 +1,28 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +// +// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING +// +// This file is providing the test runner to use when running extension tests. +// By default the test runner in use is Mocha based. +// +// You can provide your own test runner if you want to override it by exporting +// a function run(testRoot: string, clb: (error:Error) => void) that the extension +// host can call to run the tests. The test runner is expected to use console.log +// to report the results back to the caller. When the tests are finished, return +// a possible error to the callback or null if none. + +const testRunner = require('../../../test/integration/electron/testrunner'); + +// You can directly control Mocha options by uncommenting the following lines +// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info +testRunner.configure({ + ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.) + useColors: (!process.env.BUILD_ARTIFACTSTAGINGDIRECTORY && process.platform !== 'win32'), // colored output from test results (only windows cannot handle) + timeout: 60000, +}); + +export = testRunner; diff --git a/extensions/typescript-language-features/src/test/completions.test.ts b/extensions/typescript-language-features/src/test/smoke/completions.test.ts similarity index 99% rename from extensions/typescript-language-features/src/test/completions.test.ts rename to extensions/typescript-language-features/src/test/smoke/completions.test.ts index 1e651274541..b89226c5098 100644 --- a/extensions/typescript-language-features/src/test/completions.test.ts +++ b/extensions/typescript-language-features/src/test/smoke/completions.test.ts @@ -5,9 +5,9 @@ import 'mocha'; import * as vscode from 'vscode'; -import { disposeAll } from '../utils/dispose'; -import { acceptFirstSuggestion, typeCommitCharacter } from './suggestTestHelpers'; -import { assertEditorContents, Config, createTestEditor, enumerateConfig, joinLines, updateConfig, VsCodeConfiguration } from './testUtils'; +import { disposeAll } from '../../utils/dispose'; +import { acceptFirstSuggestion, typeCommitCharacter } from '../../test/suggestTestHelpers'; +import { assertEditorContents, Config, createTestEditor, enumerateConfig, joinLines, updateConfig, VsCodeConfiguration } from '../../test/testUtils'; const testDocumentUri = vscode.Uri.parse('untitled:test.ts'); diff --git a/extensions/typescript-language-features/src/test/fixAll.test.ts b/extensions/typescript-language-features/src/test/smoke/fixAll.test.ts similarity index 96% rename from extensions/typescript-language-features/src/test/fixAll.test.ts rename to extensions/typescript-language-features/src/test/smoke/fixAll.test.ts index 97ec0679e47..303693f35e5 100644 --- a/extensions/typescript-language-features/src/test/fixAll.test.ts +++ b/extensions/typescript-language-features/src/test/smoke/fixAll.test.ts @@ -6,8 +6,8 @@ import 'mocha'; import * as assert from 'assert'; import * as vscode from 'vscode'; -import { disposeAll } from '../utils/dispose'; -import { createTestEditor, wait, joinLines } from './testUtils'; +import { disposeAll } from '../../utils/dispose'; +import { createTestEditor, wait, joinLines } from '../../test/testUtils'; const testDocumentUri = vscode.Uri.parse('untitled:test.ts'); diff --git a/extensions/typescript-language-features/src/test/smoke/index.ts b/extensions/typescript-language-features/src/test/smoke/index.ts new file mode 100644 index 00000000000..7c6b176189c --- /dev/null +++ b/extensions/typescript-language-features/src/test/smoke/index.ts @@ -0,0 +1,28 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +// +// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING +// +// This file is providing the test runner to use when running extension tests. +// By default the test runner in use is Mocha based. +// +// You can provide your own test runner if you want to override it by exporting +// a function run(testRoot: string, clb: (error:Error) => void) that the extension +// host can call to run the tests. The test runner is expected to use console.log +// to report the results back to the caller. When the tests are finished, return +// a possible error to the callback or null if none. + +const testRunner = require('../../../../../test/integration/electron/testrunner'); + +// You can directly control Mocha options by uncommenting the following lines +// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info +testRunner.configure({ + ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.) + useColors: (!process.env.BUILD_ARTIFACTSTAGINGDIRECTORY && process.platform !== 'win32'), // colored output from test results (only windows cannot handle) + timeout: 60000, +}); + +export = testRunner; diff --git a/extensions/typescript-language-features/src/test/quickFix.test.ts b/extensions/typescript-language-features/src/test/smoke/quickFix.test.ts similarity index 98% rename from extensions/typescript-language-features/src/test/quickFix.test.ts rename to extensions/typescript-language-features/src/test/smoke/quickFix.test.ts index 169cc91dee3..a22118201fe 100644 --- a/extensions/typescript-language-features/src/test/quickFix.test.ts +++ b/extensions/typescript-language-features/src/test/smoke/quickFix.test.ts @@ -6,8 +6,8 @@ import * as assert from 'assert'; import 'mocha'; import * as vscode from 'vscode'; -import { disposeAll } from '../utils/dispose'; -import { createTestEditor, joinLines, retryUntilDocumentChanges, wait } from './testUtils'; +import { disposeAll } from '../../utils/dispose'; +import { createTestEditor, joinLines, retryUntilDocumentChanges, wait } from '../../test/testUtils'; suite.skip('TypeScript Quick Fix', () => { diff --git a/extensions/typescript-language-features/src/test/referencesCodeLens.test.ts b/extensions/typescript-language-features/src/test/smoke/referencesCodeLens.test.ts similarity index 97% rename from extensions/typescript-language-features/src/test/referencesCodeLens.test.ts rename to extensions/typescript-language-features/src/test/smoke/referencesCodeLens.test.ts index 80ecd3a5499..4a7fbd1ffb5 100644 --- a/extensions/typescript-language-features/src/test/referencesCodeLens.test.ts +++ b/extensions/typescript-language-features/src/test/smoke/referencesCodeLens.test.ts @@ -6,8 +6,8 @@ import * as assert from 'assert'; import 'mocha'; import * as vscode from 'vscode'; -import { disposeAll } from '../utils/dispose'; -import { createTestEditor, wait } from './testUtils'; +import { disposeAll } from '../../utils/dispose'; +import { createTestEditor, wait } from '../../test/testUtils'; type VsCodeConfiguration = { [key: string]: any }; diff --git a/extensions/typescript-language-features/src/test/cachedResponse.test.ts b/extensions/typescript-language-features/src/test/unit/cachedResponse.test.ts similarity index 96% rename from extensions/typescript-language-features/src/test/cachedResponse.test.ts rename to extensions/typescript-language-features/src/test/unit/cachedResponse.test.ts index ae05f5d4426..1b0dd441120 100644 --- a/extensions/typescript-language-features/src/test/cachedResponse.test.ts +++ b/extensions/typescript-language-features/src/test/unit/cachedResponse.test.ts @@ -6,9 +6,9 @@ import * as assert from 'assert'; import 'mocha'; import * as vscode from 'vscode'; -import type * as Proto from '../protocol'; -import { CachedResponse } from '../tsServer/cachedResponse'; -import { ServerResponse } from '../typescriptService'; +import type * as Proto from '../../protocol'; +import { CachedResponse } from '../../tsServer/cachedResponse'; +import { ServerResponse } from '../../typescriptService'; suite('CachedResponse', () => { test('should cache simple response for same document', async () => { diff --git a/extensions/typescript-language-features/src/test/functionCallSnippet.test.ts b/extensions/typescript-language-features/src/test/unit/functionCallSnippet.test.ts similarity index 99% rename from extensions/typescript-language-features/src/test/functionCallSnippet.test.ts rename to extensions/typescript-language-features/src/test/unit/functionCallSnippet.test.ts index 5c8cf18c73c..c5f8e8539aa 100644 --- a/extensions/typescript-language-features/src/test/functionCallSnippet.test.ts +++ b/extensions/typescript-language-features/src/test/unit/functionCallSnippet.test.ts @@ -9,7 +9,7 @@ import * as assert from 'assert'; import 'mocha'; import * as vscode from 'vscode'; -import { snippetForFunctionCall } from '../utils/snippetForFunctionCall'; +import { snippetForFunctionCall } from '../../utils/snippetForFunctionCall'; suite('typescript function call snippets', () => { test('Should use label as function name', async () => { diff --git a/extensions/typescript-language-features/src/test/unit/index.ts b/extensions/typescript-language-features/src/test/unit/index.ts new file mode 100644 index 00000000000..7c6b176189c --- /dev/null +++ b/extensions/typescript-language-features/src/test/unit/index.ts @@ -0,0 +1,28 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +// +// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING +// +// This file is providing the test runner to use when running extension tests. +// By default the test runner in use is Mocha based. +// +// You can provide your own test runner if you want to override it by exporting +// a function run(testRoot: string, clb: (error:Error) => void) that the extension +// host can call to run the tests. The test runner is expected to use console.log +// to report the results back to the caller. When the tests are finished, return +// a possible error to the callback or null if none. + +const testRunner = require('../../../../../test/integration/electron/testrunner'); + +// You can directly control Mocha options by uncommenting the following lines +// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info +testRunner.configure({ + ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.) + useColors: (!process.env.BUILD_ARTIFACTSTAGINGDIRECTORY && process.platform !== 'win32'), // colored output from test results (only windows cannot handle) + timeout: 60000, +}); + +export = testRunner; diff --git a/extensions/typescript-language-features/src/test/jsDocCompletions.test.ts b/extensions/typescript-language-features/src/test/unit/jsDocCompletions.test.ts similarity index 92% rename from extensions/typescript-language-features/src/test/jsDocCompletions.test.ts rename to extensions/typescript-language-features/src/test/unit/jsDocCompletions.test.ts index d824fbb4f5d..a347c5b67d0 100644 --- a/extensions/typescript-language-features/src/test/jsDocCompletions.test.ts +++ b/extensions/typescript-language-features/src/test/unit/jsDocCompletions.test.ts @@ -5,9 +5,9 @@ import 'mocha'; import * as vscode from 'vscode'; -import { disposeAll } from '../utils/dispose'; -import { acceptFirstSuggestion } from './suggestTestHelpers'; -import { assertEditorContents, Config, createTestEditor, CURSOR, enumerateConfig, insertModesValues, joinLines, updateConfig, VsCodeConfiguration } from './testUtils'; +import { disposeAll } from '../../utils/dispose'; +import { acceptFirstSuggestion } from '../suggestTestHelpers'; +import { assertEditorContents, Config, createTestEditor, CURSOR, enumerateConfig, insertModesValues, joinLines, updateConfig, VsCodeConfiguration } from '../testUtils'; const testDocumentUri = vscode.Uri.parse('untitled:test.ts'); diff --git a/extensions/typescript-language-features/src/test/jsdocSnippet.test.ts b/extensions/typescript-language-features/src/test/unit/jsdocSnippet.test.ts similarity index 94% rename from extensions/typescript-language-features/src/test/jsdocSnippet.test.ts rename to extensions/typescript-language-features/src/test/unit/jsdocSnippet.test.ts index 89464a2dd44..ebf1552df33 100644 --- a/extensions/typescript-language-features/src/test/jsdocSnippet.test.ts +++ b/extensions/typescript-language-features/src/test/unit/jsdocSnippet.test.ts @@ -6,8 +6,8 @@ import * as assert from 'assert'; import 'mocha'; import * as vscode from 'vscode'; -import { templateToSnippet } from '../languageFeatures/jsDocCompletions'; -import { joinLines } from './testUtils'; +import { templateToSnippet } from '../../languageFeatures/jsDocCompletions'; +import { joinLines } from '../testUtils'; suite('typescript.jsDocSnippet', () => { diff --git a/extensions/typescript-language-features/src/test/onEnter.test.ts b/extensions/typescript-language-features/src/test/unit/onEnter.test.ts similarity index 99% rename from extensions/typescript-language-features/src/test/onEnter.test.ts rename to extensions/typescript-language-features/src/test/unit/onEnter.test.ts index 5ec03f5c40a..16f08b4960e 100644 --- a/extensions/typescript-language-features/src/test/onEnter.test.ts +++ b/extensions/typescript-language-features/src/test/unit/onEnter.test.ts @@ -6,7 +6,7 @@ import * as assert from 'assert'; import 'mocha'; import * as vscode from 'vscode'; -import { CURSOR, withRandomFileEditor, wait, joinLines } from './testUtils'; +import { CURSOR, withRandomFileEditor, wait, joinLines } from '../testUtils'; const onDocumentChange = (doc: vscode.TextDocument): Promise => { return new Promise(resolve => { diff --git a/extensions/typescript-language-features/src/test/previewer.test.ts b/extensions/typescript-language-features/src/test/unit/previewer.test.ts similarity index 96% rename from extensions/typescript-language-features/src/test/previewer.test.ts rename to extensions/typescript-language-features/src/test/unit/previewer.test.ts index b92c0019631..38bfc14ecbb 100644 --- a/extensions/typescript-language-features/src/test/previewer.test.ts +++ b/extensions/typescript-language-features/src/test/unit/previewer.test.ts @@ -5,7 +5,7 @@ import * as assert from 'assert'; import 'mocha'; -import { tagsMarkdownPreview, markdownDocumentation } from '../utils/previewer'; +import { tagsMarkdownPreview, markdownDocumentation } from '../../utils/previewer'; suite('typescript.previewer', () => { test('Should ignore hyphens after a param tag', async () => { diff --git a/extensions/typescript-language-features/src/test/requestQueue.test.ts b/extensions/typescript-language-features/src/test/unit/requestQueue.test.ts similarity index 98% rename from extensions/typescript-language-features/src/test/requestQueue.test.ts rename to extensions/typescript-language-features/src/test/unit/requestQueue.test.ts index 9103792686e..1568a95e43c 100644 --- a/extensions/typescript-language-features/src/test/requestQueue.test.ts +++ b/extensions/typescript-language-features/src/test/unit/requestQueue.test.ts @@ -5,7 +5,7 @@ import * as assert from 'assert'; import 'mocha'; -import { RequestQueue, RequestQueueingType } from '../tsServer/requestQueue'; +import { RequestQueue, RequestQueueingType } from '../../tsServer/requestQueue'; suite('RequestQueue', () => { test('should be empty on creation', async () => { diff --git a/extensions/typescript-language-features/src/test/server.test.ts b/extensions/typescript-language-features/src/test/unit/server.test.ts similarity index 84% rename from extensions/typescript-language-features/src/test/server.test.ts rename to extensions/typescript-language-features/src/test/unit/server.test.ts index d95b16e06ba..09ea48e00ef 100644 --- a/extensions/typescript-language-features/src/test/server.test.ts +++ b/extensions/typescript-language-features/src/test/unit/server.test.ts @@ -6,14 +6,14 @@ import * as assert from 'assert'; import 'mocha'; import * as stream from 'stream'; -import type * as Proto from '../protocol'; -import { NodeRequestCanceller } from '../tsServer/cancellation.electron'; -import { ProcessBasedTsServer, TsServerProcess } from '../tsServer/server'; -import { ServerType } from '../typescriptService'; -import { nulToken } from '../utils/cancellation'; -import { Logger } from '../utils/logger'; -import { TelemetryReporter } from '../utils/telemetry'; -import Tracer from '../utils/tracer'; +import type * as Proto from '../../protocol'; +import { NodeRequestCanceller } from '../../tsServer/cancellation.electron'; +import { ProcessBasedTsServer, TsServerProcess } from '../../tsServer/server'; +import { ServerType } from '../../typescriptService'; +import { nulToken } from '../../utils/cancellation'; +import { Logger } from '../../utils/logger'; +import { TelemetryReporter } from '../../utils/telemetry'; +import Tracer from '../../utils/tracer'; const NoopTelemetryReporter = new class implements TelemetryReporter { diff --git a/scripts/test-integration.bat b/scripts/test-integration.bat index 6634ee9df11..bfa29b83e32 100644 --- a/scripts/test-integration.bat +++ b/scripts/test-integration.bat @@ -50,8 +50,8 @@ if %errorlevel% neq 0 exit /b %errorlevel% call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\vscode-api-tests\testworkspace.code-workspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=%~dp0\..\extensions\vscode-api-tests --extensionTestsPath=%~dp0\..\extensions\vscode-api-tests\out\workspace-tests --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR% if %errorlevel% neq 0 exit /b %errorlevel% -REM call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\typescript-language-features\test-workspace --extensionDevelopmentPath=%~dp0\..\extensions\typescript-language-features --extensionTestsPath=%~dp0\..\extensions\typescript-language-features\out\test --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR% -REM if %errorlevel% neq 0 exit /b %errorlevel% +call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\typescript-language-features\test-workspace --extensionDevelopmentPath=%~dp0\..\extensions\typescript-language-features --extensionTestsPath=%~dp0\..\extensions\typescript-language-features\out\test\unit --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR% +if %errorlevel% neq 0 exit /b %errorlevel% call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\markdown-language-features\test-workspace --extensionDevelopmentPath=%~dp0\..\extensions\markdown-language-features --extensionTestsPath=%~dp0\..\extensions\markdown-language-features\out\test --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR% if %errorlevel% neq 0 exit /b %errorlevel% diff --git a/scripts/test-integration.sh b/scripts/test-integration.sh index 3bb8dce32bc..d59d608d191 100755 --- a/scripts/test-integration.sh +++ b/scripts/test-integration.sh @@ -75,8 +75,8 @@ after_suite "$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS $ROOT/extensions/markdown-language-features/test-workspace --extensionDevelopmentPath=$ROOT/extensions/markdown-language-features --extensionTestsPath=$ROOT/extensions/markdown-language-features/out/test --disable-telemetry --crash-reporter-directory=$VSCODECRASHDIR --no-cached-data --disable-updates --disable-extensions --user-data-dir=$VSCODEUSERDATADIR after_suite -#"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS $ROOT/extensions/typescript-language-features/test-workspace --extensionDevelopmentPath=$ROOT/extensions/typescript-language-features --extensionTestsPath=$ROOT/extensions/typescript-language-features/out/test --disable-telemetry --crash-reporter-directory=$VSCODECRASHDIR --no-cached-data --disable-updates --disable-extensions --user-data-dir=$VSCODEUSERDATADIR -# after_suite +"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS $ROOT/extensions/typescript-language-features/test-workspace --extensionDevelopmentPath=$ROOT/extensions/typescript-language-features --extensionTestsPath=$ROOT/extensions/typescript-language-features/out/test/unit --disable-telemetry --crash-reporter-directory=$VSCODECRASHDIR --no-cached-data --disable-updates --disable-extensions --user-data-dir=$VSCODEUSERDATADIR +after_suite "$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS $ROOT/extensions/emmet/out/test/test-fixtures --extensionDevelopmentPath=$ROOT/extensions/emmet --extensionTestsPath=$ROOT/extensions/emmet/out/test --disable-telemetry --crash-reporter-directory=$VSCODECRASHDIR --no-cached-data --disable-updates --disable-extensions --user-data-dir=$VSCODEUSERDATADIR after_suite