From 46c2494cb08e55637e9f35d6aaa664a3d029b9f0 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Tue, 7 Jul 2020 17:38:03 -0700 Subject: [PATCH] Enable ts tests on ./test-integration.sh (#101826) * Enable ts tests on ./test-integration.sh * Fix join lines for windows * Fixing more tests for windows Make sure we use the correct new line character * Update test-ingration scripts --- .../src/test/completions.test.ts | 12 ++++---- .../src/test/onEnter.test.ts | 28 +++++++++++++++---- .../src/test/testUtils.ts | 7 +++-- scripts/test-integration.bat | 9 ++++-- scripts/test-integration.sh | 1 + 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/extensions/typescript-language-features/src/test/completions.test.ts b/extensions/typescript-language-features/src/test/completions.test.ts index 4ac284336eb..92a7da63f92 100644 --- a/extensions/typescript-language-features/src/test/completions.test.ts +++ b/extensions/typescript-language-features/src/test/completions.test.ts @@ -16,10 +16,12 @@ const insertModes = Object.freeze(['insert', 'replace']); suite('TypeScript Completions', () => { const configDefaults: VsCodeConfiguration = Object.freeze({ [Config.autoClosingBrackets]: 'always', - [Config.completeFunctionCalls]: false, + [Config.typescriptCompleteFunctionCalls]: false, [Config.insertMode]: 'insert', [Config.snippetSuggestions]: 'none', [Config.suggestSelection]: 'first', + [Config.javascriptQuoteStyle]: 'double', + [Config.typescriptQuoteStyle]: 'double', }); const _disposables: vscode.Disposable[] = []; @@ -178,7 +180,7 @@ suite('TypeScript Completions', () => { }); test('completeFunctionCalls should complete function parameters when at end of word', async () => { - await updateConfig(testDocumentUri, { [Config.completeFunctionCalls]: true }); + await updateConfig(testDocumentUri, { [Config.typescriptCompleteFunctionCalls]: true }); // Complete with-in word const editor = await createTestEditor(testDocumentUri, @@ -196,7 +198,7 @@ suite('TypeScript Completions', () => { }); test.skip('completeFunctionCalls should complete function parameters when within word', async () => { - await updateConfig(testDocumentUri, { [Config.completeFunctionCalls]: true }); + await updateConfig(testDocumentUri, { [Config.typescriptCompleteFunctionCalls]: true }); const editor = await createTestEditor(testDocumentUri, `function abcdef(x, y, z) { }`, @@ -213,7 +215,7 @@ suite('TypeScript Completions', () => { }); test('completeFunctionCalls should not complete function parameters at end of word if we are already in something that looks like a function call, #18131', async () => { - await updateConfig(testDocumentUri, { [Config.completeFunctionCalls]: true }); + await updateConfig(testDocumentUri, { [Config.typescriptCompleteFunctionCalls]: true }); const editor = await createTestEditor(testDocumentUri, `function abcdef(x, y, z) { }`, @@ -230,7 +232,7 @@ suite('TypeScript Completions', () => { }); test.skip('completeFunctionCalls should not complete function parameters within word if we are already in something that looks like a function call, #18131', async () => { - await updateConfig(testDocumentUri, { [Config.completeFunctionCalls]: true }); + await updateConfig(testDocumentUri, { [Config.typescriptCompleteFunctionCalls]: true }); const editor = await createTestEditor(testDocumentUri, `function abcdef(x, y, z) { }`, diff --git a/extensions/typescript-language-features/src/test/onEnter.test.ts b/extensions/typescript-language-features/src/test/onEnter.test.ts index c7d6c3a45dd..b6b05699854 100644 --- a/extensions/typescript-language-features/src/test/onEnter.test.ts +++ b/extensions/typescript-language-features/src/test/onEnter.test.ts @@ -6,7 +6,7 @@ import * as assert from 'assert'; import 'mocha'; import * as vscode from 'vscode'; -import { CURSOR, withRandomFileEditor } from './testUtils'; +import { CURSOR, withRandomFileEditor, joinLines } from './testUtils'; const onDocumentChange = (doc: vscode.TextDocument): Promise => { return new Promise(resolve => { @@ -31,28 +31,44 @@ suite('OnEnter', () => { test('should indent after if block with braces', () => { return withRandomFileEditor(`if (true) {${CURSOR}`, 'js', async (_editor, document) => { await type(document, '\nx'); - assert.strictEqual(document.getText(), `if (true) {\n x`); + assert.strictEqual( + document.getText(), + joinLines( + `if (true) {`, + ` x`)); }); }); test('should indent within empty object literal', () => { return withRandomFileEditor(`({${CURSOR}})`, 'js', async (_editor, document) => { await type(document, '\nx'); - assert.strictEqual(document.getText(), `({\n x\n})`); + assert.strictEqual( + document.getText(), + joinLines(`({`, + ` x`, + `})`)); }); }); test('should indent after simple jsx tag with attributes', () => { return withRandomFileEditor(`const a =
${CURSOR}`, 'jsx', async (_editor, document) => { await type(document, '\nx'); - assert.strictEqual(document.getText(), `const a =
\n x`); + assert.strictEqual( + document.getText(), + joinLines( + `const a =
`, + ` x`)); }); }); test('should indent after simple jsx tag with attributes', () => { return withRandomFileEditor(`const a =
${CURSOR}`, 'jsx', async (_editor, document) => { await type(document, '\nx'); - assert.strictEqual(document.getText(), `const a =
\n x`); + assert.strictEqual( + document.getText(), + joinLines( + `const a =
`, + ` x`)); }); }); -}); \ No newline at end of file +}); diff --git a/extensions/typescript-language-features/src/test/testUtils.ts b/extensions/typescript-language-features/src/test/testUtils.ts index 6d7c1e83761..ea5e41a26a8 100644 --- a/extensions/typescript-language-features/src/test/testUtils.ts +++ b/extensions/typescript-language-features/src/test/testUtils.ts @@ -70,7 +70,7 @@ export function withRandomFileEditor( export const wait = (ms: number) => new Promise(resolve => setTimeout(() => resolve(), ms)); -export const joinLines = (...args: string[]) => args.join('\n'); +export const joinLines = (...args: string[]) => args.join(os.platform() === 'win32' ? '\r\n' : '\n'); export async function createTestEditor(uri: vscode.Uri, ...lines: string[]) { const document = await vscode.workspace.openTextDocument(uri); @@ -102,6 +102,7 @@ export type VsCodeConfiguration = { [key: string]: any }; export async function updateConfig(documentUri: vscode.Uri, newConfig: VsCodeConfiguration): Promise { const oldConfig: VsCodeConfiguration = {}; const config = vscode.workspace.getConfiguration(undefined, documentUri); + for (const configKey of Object.keys(newConfig)) { oldConfig[configKey] = config.get(configKey); await new Promise((resolve, reject) => @@ -113,10 +114,12 @@ export async function updateConfig(documentUri: vscode.Uri, newConfig: VsCodeCon export const Config = Object.freeze({ autoClosingBrackets: 'editor.autoClosingBrackets', - completeFunctionCalls: 'typescript.suggest.completeFunctionCalls', + typescriptCompleteFunctionCalls: 'typescript.suggest.completeFunctionCalls', insertMode: 'editor.suggest.insertMode', snippetSuggestions: 'editor.snippetSuggestions', suggestSelection: 'editor.suggestSelection', + javascriptQuoteStyle: 'javascript.preferences.quoteStyle', + typescriptQuoteStyle: 'typescript.preferences.quoteStyle', } as const); export const insertModesValues = Object.freeze(['insert', 'replace']); diff --git a/scripts/test-integration.bat b/scripts/test-integration.bat index 2c50bff7c77..4c76f04373c 100644 --- a/scripts/test-integration.bat +++ b/scripts/test-integration.bat @@ -38,8 +38,8 @@ if "%INTEGRATION_TEST_ELECTRON_PATH%"=="" ( ) :: Integration & performance tests in AMD -call .\scripts\test.bat --runGlob **\*.integrationTest.js %* -if %errorlevel% neq 0 exit /b %errorlevel% +::call .\scripts\test.bat --runGlob **\*.integrationTest.js %* +::if %errorlevel% neq 0 exit /b %errorlevel% :: Tests in the extension host @@ -55,7 +55,10 @@ if %errorlevel% neq 0 exit /b %errorlevel% call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\vscode-colorize-tests\test --extensionDevelopmentPath=%~dp0\..\extensions\vscode-colorize-tests --extensionTestsPath=%~dp0\..\extensions\vscode-colorize-tests\out --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\out\test\test-fixtures --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% . +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% +if %errorlevel% neq 0 exit /b %errorlevel% + +call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\markdown-language-features\out\test\test-fixtures --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% call "%INTEGRATION_TEST_ELECTRON_PATH%" $%~dp0\..\extensions\emmet\out\test\test-fixtures --extensionDevelopmentPath=%~dp0\..\extensions\emmet --extensionTestsPath=%~dp0\..\extensions\emmet\out\test --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR% . diff --git a/scripts/test-integration.sh b/scripts/test-integration.sh index 0e4cedd114d..480c449d2f7 100755 --- a/scripts/test-integration.sh +++ b/scripts/test-integration.sh @@ -53,6 +53,7 @@ fi "$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_NO_SANDBOX $ROOT/extensions/vscode-api-tests/testworkspace.code-workspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=$ROOT/extensions/vscode-api-tests --extensionTestsPath=$ROOT/extensions/vscode-api-tests/out/workspace-tests --disable-telemetry --crash-reporter-directory=$VSCODECRASHDIR --no-cached-data --disable-updates --disable-extensions --user-data-dir=$VSCODEUSERDATADIR "$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_NO_SANDBOX $ROOT/extensions/vscode-colorize-tests/test --extensionDevelopmentPath=$ROOT/extensions/vscode-colorize-tests --extensionTestsPath=$ROOT/extensions/vscode-colorize-tests/out --disable-telemetry --crash-reporter-directory=$VSCODECRASHDIR --no-cached-data --disable-updates --disable-extensions --user-data-dir=$VSCODEUSERDATADIR "$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_NO_SANDBOX $ROOT/extensions/markdown-language-features/out/test/test-fixtures --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 +"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_NO_SANDBOX $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 "$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_NO_SANDBOX $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 "$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_NO_SANDBOX $(mktemp -d 2>/dev/null) --enable-proposed-api=vscode.git --extensionDevelopmentPath=$ROOT/extensions/git --extensionTestsPath=$ROOT/extensions/git/out/test --disable-telemetry --crash-reporter-directory=$VSCODECRASHDIR --no-cached-data --disable-updates --disable-extensions --user-data-dir=$VSCODEUSERDATADIR